Question on java Socket

Hi all
My question is: if i make a socket connection between two computers,offcoure one is server socket and other is simple socket, then when i use printstream for that socket to write on it like
PrintStream p= new PrintStream(so.getOutputStream());
now i write like p.println(); here i am writing on port...and other port of client side listening to it, then in this whole work ,IS TCP/IP comes in picture?
if yes then i don't want that TCP/IP initiate itself , i want to make my own protocol for two computer to talk then how to start , guide me....?keep in mind that i am only using socket...


  • vijayrock
    socket and serversocket are two classes that are meant for TCP/IP implementation in JAVA.

    In the client side...
    1.a new socket is created
    2.socket attempts to connect to the remote host
    3.Once the connection is established,the local and remote hosts get I/P and O/P streams and uses them for sending data to each other.
    4.once the transmission is complete,one or both the sides closes the connection

    In the server side
    1.a new serversocket is created on a port
    2.serversocket listens to the particular port for any incoming connection using the accept().accept() blocks until a client attempts to connect.when the client tries to connect,accept() returns a socket object connecting the client and the server
    3.server and the client interact according to an agreed upon protocol until the close() is called
    4.both closes the connection.
    5.then the server gets back to the step 2(above).

    TCP/IP is the internationally agreed protocol for connection oriented data transfer.
    u can well propose any concept.It becomes a protocol only when its accepted as a standard that is to be about TCP/IP and UDP much more so that u might get more ideas about them(like u would get to know the problems involved in them).
  • niraj.kumar
    There are two kind of protocol ... TCP and UDP if any case you have 2 use these ....

You are reading an archived discussion.

Related Posts

Hi i want to use USB port in c , can i point to it?? i am using it for printer.. i think there is sum hub for usb's in...
To all left-handers on CrazyEngineers - 😁HaPpy Left Handers Day 😁 ...and don't ask me why I'm damn so happy today 😛 We've following super left-handers in the world -...
im a new bie.😒 need help on final project.. i dun have much ideas..😕 n my projects must consist of 2 IC.. if anyone can help me,i would be greatful.....
In continuation with our "CE Ultimate Project Ideas & Seminar Topics" series for engineering students; let's build "CE - Ultimate mini Project Ideas & Seminar Topics for Mechanical Engineering" Everyone,...
hi i am pri.... actuall dis is my 1st post so i dnt no whether i m posting it to the right place or not..... i am in desperate need...