[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
>CS assignment >write network code in Java I hate the
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 50
Thread images: 5
File: pepe.jpg (11 KB, 258x195) Image search: [Google]
pepe.jpg
11 KB, 258x195
>CS assignment
>write network code in Java

I hate the fuck that Java has 50+ different ways for input/output
>>
>>54595907
stupid frogposter
>>
Just use Netty faggot
>>
Do it in C then.

See you in 3 weeks after you've opened your first socket.
>>
>>54595907
Pajeet please
>>
>>54595907
Iktf OP. C sockets are unironically literally easier.
>>
>>54595907

hello yes if you need help with youre assignment you can post the assignments here

i am high level master programmer of the java in my company, i can help you program the assignments
>>
>>54599059
hello mr. pajeet very nice to meet you
>>
File: 1461850271455.jpg (40 KB, 657x527) Image search: [Google]
1461850271455.jpg
40 KB, 657x527
>>54599059
hello yes yes i can hear you
>>
>>54595988

So much this.

C sockets suck so much, they bend light.

// Java
socket = new Socket("localhost", 3141); OutputStream myOutputStream = socket.getOutputStream();

// C
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr,
(char *)&serv_addr.sin_addr.s_addr,
server->h_length);
serv_addr.sin_port = htons(portno);


What the freaking hell?
>>
>>54599318
Jesus, that C code is murder on my eyes. Didnt who ever wrote that stop to think about readability?
>>
>>54599644
Readability is a crutch. Code should be as complicated as possible to filter out lesser humans with sub-130 IQs.
>>
>>54595907
most of them are there for backwards compatibility, just use the nio stuff
>>
>>54599318
>>54599644
Well thats the price you pay for more control and power
Its not even that hard

int sock;
sock = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in sock_info;
sock_info.sin_port = htons(80);
sock_info.sin_addr = inet_addr("1.2.3.4");
connect(sock, (struct sockaddr*)&sock_info, sizeof(sock_info));


Then you can write and read as you wish to
>>
>>54599644
Newbies code like that.
>>
>>54599318
Doesn't look any worse than code in native Win32 semfam
>>
>>54595988
I enjoyed my network programming in C classes way more than any Java assignments.
>>
It's CURRENT_YEAR so use Java 8 and the java.nio package
>>
>work as java developer
>see this shit
>kid asking stupid questions
>just go to stackoverflow
>use the first shit that works
>alt + f4
>don't look back until somebody pesters you about it

when will you kids learn, when god hands you lemons, you make lemonade
>>
>>54601875
>>just go to stackoverflow
>see 10 year old java.io abomination
>try hardest to use it
>no results
>get fired

thank you mr. java developer
>>
>>54599059
please do the needful with the task at hand
>>
>>54601759
>Doesn't look any worse than code in native Win32 semfam
Thats like saying AIDS is worse than flu farn
>>
>>54601312
>just use the nio stuff
the fuck is nio?
>>
>>54595907
>I hate the fuck that Java has 50+ different ways for input/output
Let's trade. I miss having flexible IO, and I'm stuck in C++.
>>
>>54602472
https://docs.oracle.com/javase/7/docs/api/java/nio/package-summary.html
>>
>>54602472
stands for Non-blocking I/O

https://docs.oracle.com/javase/7/docs/api/java/nio/package-summary.html
>>
>>54602585
hey, fuck you
>>
>>54602601
rude
>>
Doesn't java have something that is as easy to use as zeromq?
>>
>>54602617
what does a message queue framework have to do with anything?

and don't act like it's part of the core language
>>
>>54602592
New I/O is a better name because of stuff like java.nio.file which has little to do with non-blocking
>>
>>54595945

stupid poster,who post "stupid frogposter".
>>
>>54602649
Non-blocking part of it is basically all the hype though...

side question: Has anybody implemented SSH using NIO yet?
there seem to be legitimately no good SSH libraries for Java
>>
>>54602666
Paths and the Files class are pretty neat though
>>
>>54595907
Is the teacher Pajeet ?
>>
>>54602909
Nope, I study in a white country and not Amerifat-land
>>
File: kek.jpg (54 KB, 600x600) Image search: [Google]
kek.jpg
54 KB, 600x600
>>54595907
Client - Server communication

>python 5 lines of code
>java 30 lines of code + 4 catches

Stream in stream in stream, output another fucking stream


Few classes just to communicate, another class for objects.

Is java really that superior?
>>
>>54603492
>java 30 lines of code + 4 catches
>Stream in stream in stream, output another fucking stream
you're vastly exaggerating or using some library code from 20 years ago
>Is java really that superior?
it's tens to hundreds times faster
>>
>>54603492
What a retarded strawman, Python only offers syntactic sugar, the rest is purely based on the library you use.
>>
>>54603665
When you call python syntax syntetic sugar then whats is the name of java syntax?
>>
>>54599318
The java code doesnt make any sense, wtf is an output stream?
>>
>CS
>programming
It's your own fault for choosing crap school.
>>
>>54603790
Welp, If we use male - female analogy, then outputstream is male
>>
>>54603731
What?
>>
>>54603790
Basically anything that ends with Stream is an object that has two methods: boolean .hasNext() and byte .next().

.next() returns the next byte and you have to handle it. So an output stream of a socket is how you get the data from it.
>>
>>54603790
>The java code doesnt make any sense
>but that C clusterfuck does
>>
>>54596148
>>54599059
why do you keep saying java is for rajesh's

it's a fine language, low enough level, versatile (android/fast scalable web back end/web applets/desktop apps), fast enough... and the JVM can run Scala/Clojure

I don't see what's bad with java
>>
>>54604784

You see, on /g/ people often say things they don't really mean.
It's called "trolling" or "pretending to be retarded"..

In fact you're well off doing exactly the opposite of what /g/ tells you to do.
>>
>>54595907
here, no noise
>>
>>54599309
no noise
Thread replies: 50
Thread images: 5

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.