CrazyEngineers
  • umesh936
    umesh936

    MemberAug 12, 2008

    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...
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • vijayrock

    MemberAug 22, 2008

    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 followed.study 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).
    Are you sure? This action cannot be undone.
    Cancel
  • niraj.kumar

    MemberAug 23, 2008

    There are two kind of protocol ... TCP and UDP if any case you have 2 use these ....
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register