The Artima Developer Community
Sponsored Link

Java Answers Forum
TCP/IP in Java

6 replies on 1 page. Most recent reply: Jul 2, 2002 10:17 PM by Pavan Kumar Keely

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
bob

Posts: 3
Nickname: rpmbrylane
Registered: Jul, 2002

TCP/IP in Java Posted: Jul 1, 2002 7:34 AM
Reply to this message Reply
Advertisement
I am trying to send a packet using TCPIP in java with a length of zero. Any thoughts on how to do this?


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: TCP/IP in Java Posted: Jul 1, 2002 9:50 AM
Reply to this message Reply
I don't understand how you can send a packet of length zero. That makes no sense. That's the same as sending nothing.

bob

Posts: 3
Nickname: rpmbrylane
Registered: Jul, 2002

Re: TCP/IP in Java Posted: Jul 1, 2002 11:47 AM
Reply to this message Reply
I want to send a packet that has no data in it.

bob

Posts: 3
Nickname: rpmbrylane
Registered: Jul, 2002

Re: TCP/IP in Java Posted: Jul 1, 2002 11:55 AM
Reply to this message Reply
I need to be more specific. I am sending other data also but the server I am sending the requests to is looking for a packet with zero length (a packet with no data) as a terminating condition. So the server blocks until it finds a packet of zero length.

Thanks

Hiran

Posts: 41
Nickname: jclu
Registered: Mar, 2002

Re: TCP/IP in Java Posted: Jul 1, 2002 1:56 PM
Reply to this message Reply
Check the java documentation. I believe there's a class that allows you to send a stream (or packets) of bytes across a network I/O stream. Establish a connection with the host (or server), and when you need to, just send a byte containing 0, or an array of bytes with length 0. I don't remember what class you should use, but check all the classes in the java.io package. Hope this helps.
Hiran

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: TCP/IP in Java Posted: Jul 1, 2002 3:36 PM
Reply to this message Reply
Bob,

I believe it's a really bad idea to mix Application level sementics with another layer (transmition layer syntax).

Why don't you try to make things simple ?
Look at the RFC for anything (SMTP, HTTP, ...), there is always a command to terminate things, no hard to understand syntax meaning special case !
Certainly not to terminate a communication.

Thomas SMETS,
SCJP2 - Brussels

Pavan Kumar Keely

Posts: 7
Nickname: pavan
Registered: Mar, 2002

Re: TCP/IP in Java Posted: Jul 2, 2002 10:17 PM
Reply to this message Reply
hi,

you can do onething,
as the server is recognizing the zero length data as the last message and disconnecting, you can send a zero length data with a line feed. like

stream.println("");

stream can be anythign which supports printlns. But as far as the logic is considered you can't really send the zero length packet. and if you do the thing that I said above that won't mix the application layer semantics with transmission layer semantics.

This is same as sending a "." in a line without any data in SMTP.

hope you'll find it useful...
if not mail me with any query you have I'll try to solve that.

bye
Pavan Kumar Keely,
Software Engineer, Quillisd India

Flat View: This topic has 6 replies on 1 page
Topic: Java Mail Previous Topic   Next Topic Topic: How to set  the icon of the frame create by float JToolbar

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use