[1633] in java-interest
Re: SEND IN SOCKET
daemon@ATHENA.MIT.EDU (Nicholas Geh)
Tue Sep 12 01:07:23 1995
Date: Tue, 12 Sep 1995 08:32:46 +0900 (SDT)
From: Nicholas Geh <nik@mailhub.ncb.gov.sg>
To: Richard Wahongan <n1061925@dodo.fit.qut.edu.au>
Cc: Java Interest <java-interest@java.Eng.Sun.COM>
In-Reply-To: <Pine.SOL.3.91.950911163119.4912A-100000@dodo>
Richard,
>
> How can I send data with the class socket ?
>
Can't say that I have a wealth of experience in Socket transmission, but
I just did a Chat program that uses sockets. I would recommend that you
read up on Windows and UNIX sockets transmission procedures - it is
pretty much the same commands in Java, except that instead of calling
functions, you have to call the method (which goes by the same names) in
the context of a class. Pay attention to methods such as the accept(),
listen(), bindToPort(), connect(). Other than that, once you open a
socket, you would transmit data using inputstreams and outputstreams,
which can be rather messy since data transfer can be asynchrous. If you
need info on this subject, check out http://www.yahoo.com and surf to the
relevant topic.
What I did was to design a custom protocol to transmit variable-length
strings, which provides an abstraction for string transfer and saves you
the trouble of having to worry about how many bytes to transmit/receive.
If you really want the code, email me. I think there are lots of you out
there who have more experience with this area and can come up with better
code than I can.
Nik
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com