Jump to content

  • Log In with Google      Sign In   
  • Create Account


[java] Java Socket Protocols


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 joeG   Members   -  Reputation: 172

Like
Likes
Like

Posted 03 March 2000 - 07:50 AM

Which protocol is java.net.Socket based on? I am trying to develop an application-specific protocol. I need to know if I should handle ''packet'' sizes or if the protocol that java.net.Socket is based on should handle packet sizes. As I mentioned in an earlier post, there is no way to control the send/receive buffers in JDK 1.1, so, therefore, the programmer is on their own as far as controlling packet size? Or not?

Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 03 March 2000 - 10:56 AM

Whoa guy, you might need to do some reading on networking before you go writing any network applications. java.net.Socket is a class that represents a socket connection, not a protocol. You make your own protocol by defining a way that a client and server can transmit data through (or over) a socket connection. Generally, protocols are unaware of any transmission packets. And lastly, why not just wrap your socket''s input stream in a buffered reader? so you''d have a buffered socket.... just a thought.

#3 joeG   Members   -  Reputation: 172

Like
Likes
Like

Posted 03 March 2000 - 11:12 AM

I''m sorry, I meant to ask the question, "Which protocol is java.net.Socket sitting on?" The real question is, "why does sending ''packets'' (''packet'' roughly equals an array full of bytes sent at once) that are larger than X amount of bytes per packet, clog the connection indefinitely (and I mean I''ve waited a lonnnnnnnng time for it to send one of these ''packets'').

And, theoretically, if you''re not able to send more than X amount of bytes over a connection then why should BufferedReader be able to????

Plus the reason I asked about which protocol does java.net.Socket sit on, is because I''m curious to discover if the underlying protocol should''ve handled a ''packet'' of data that was larger than what the buffer could handle. If not, then I should reduce the size of the packets I send through the socket. If so, then I should investigate another part of my program.

Thanks for the help though

#4 Captain Goatse   Banned   -  Reputation: 100

Like
Likes
Like

Posted 03 March 2000 - 08:19 PM

quote:
Original post by joeG

I''m sorry, I meant to ask the question, "Which protocol is java.net.Socket sitting on?" The real question is, "why does sending ''packets'' (''packet'' roughly equals an array full of bytes sent at once) that are larger than X amount of bytes per packet, clog the connection indefinitely (and I mean I''ve waited a lonnnnnnnng time for it to send one of these ''packets'').

And, theoretically, if you''re not able to send more than X amount of bytes over a connection then why should BufferedReader be able to????

Plus the reason I asked about which protocol does java.net.Socket sit on, is because I''m curious to discover if the underlying protocol should''ve handled a ''packet'' of data that was larger than what the buffer could handle. If not, then I should reduce the size of the packets I send through the socket. If so, then I should investigate another part of my program.

Thanks for the help though


Umm... I don''t know very much about these protocols, but in most games (I suspect that you are adding this in your game, correct me if I''m wrong) "packet" size is defined by user, he can choose the packet size between Isdn 64k, Isdn 128k, 56k, 33k, 28k, and 14k. And this way packets are optimized for each modem speed. Of course this requires that your protocol can handle these packet sizes

Doh, neverver mind, you asked the protocol and I answered pacets size, I hope this helps someone...


Time comes, time goes and I only am.

#5 Jim_Ross   Members   -  Reputation: 122

Like
Likes
Like

Posted 04 March 2000 - 11:28 AM

First off, wrapping your socket''s input stream in a buffered reader allows it to read more information than it normally can handle and store it for later. You dont'' specifically set packets sizes unless you are working with UDP (I think). TCP/IP guaran-damn-tees that all your information will arrive at it''s destination. Socket and URL classes will use TCP/IP to transmit data. MultiSocket and classes that begin with Datagram use UDP. All of this should be transparent to your program. If it isn''t, you are doing something wrong/very advanced/very uneccasary. If your program just stalls it''s probably because it''s not connecting the socket correctly. You should setSoTimeout(int milliseconds) before you try to read from it. Then the read() will throw an InterruptedIOException. If you check out the client/server example on the networking trail, it doesn''t mention TCP/IP at all.

Don''t confuse network protocols like TCP/IP or UDP with application protocols like HTTP or FTP.

#6 joeG   Members   -  Reputation: 172

Like
Likes
Like

Posted 04 March 2000 - 01:01 PM

Thanks




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS