Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Socket Programming

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Socket Programming

    Hi,
    I am new to java.
    I want to create a socket that can serve all the network protocols.
    can we make such type of socket in java.
    Plz anyone guide me.
    Thanks in advance.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Socket Programming

    Cross posted here.

  3. The Following User Says Thank You to GregBrannon For This Useful Post:

    sumit.tejas02 (January 15th, 2014)

  4. #3
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Socket Programming

    Quote Originally Posted by sumit.tejas02 View Post
    I want to create a socket that can serve all the network protocols.
    I suspect you don't have a clear knowledge on networking .....
    There are several kinds of "network socket", the most common are:
    - datagram sockets (UDP)
    - stream sockets (TCP).
    In Java the respective classes are java.net.DatagramSocket and java.net.Socket.

    But on "top" of these sockets, there are a moltitude of "applicative" protocols, such as HTTP, FTP, SMTP and many others, more typically on top of TCP.
    If you implement an HTTP protocol .... you are not implementing FTP or SMTP!!

    So the phrase "that can serve all the network protocols" has very little/no sense.
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

  5. #4
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Socket Programming

    Quote Originally Posted by andbin View Post
    I suspect you don't have a clear knowledge on networking .....
    There are several kinds of "network socket", the most common are:
    - datagram sockets (UDP)
    - stream sockets (TCP).
    In Java the respective classes are java.net.DatagramSocket and java.net.Socket.

    But on "top" of these sockets, there are a moltitude of "applicative" protocols, such as HTTP, FTP, SMTP and many others, more typically on top of TCP.
    If you implement an HTTP protocol .... you are not implementing FTP or SMTP!!

    So the phrase "that can serve all the network protocols" has very little/no sense.
    Thank you for your reply.
    I know there are different classes for different network protocols.
    But I want to create only one socket which can be used for not all the protocols but some of the standard protocols.
    So I just wanted to know that is there any way to create such type of socket. Is it possible in java ?

  6. #5
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Socket Programming

    Quote Originally Posted by sumit.tejas02 View Post
    But I want to create only one socket which can be used for not all the protocols but some of the standard protocols.
    So I just wanted to know that is there any way to create such type of socket. Is it possible in java ?
    Here I speak only about TCP sockets (which are more common and useful). A TCP socket (in Java java.net.Socket / java.net.ServerSocket) is only the "bottom" level at which you can establish a "long" communication with another socket somewhere on the net.

    It's exactly like the telephone line. The connection between two sockets is very very like two telephones that, upon a call from one end, the telephone company puts in communication allocating some resources for the time of the entire communication (until one end closes it). Then what you do with this established communication ..... is another story. One person can only listen, or answer to the other person only one time, or both can talk each other continuously. This is the "applicative" protocol! And this is what happens for applicative networking protocols like HTTP, FTP, SMTP, etc...

    The opening of a socket for an HTTP communication is not very different from the opening of a socket for an FTP communication. Just only the port number changes (and the address, obviously). What changes is the all rest, the format of the informations and the logic, timings, sequences to exchange them.
    If you are developing an HTTP "client" (or a "server"), for example, you are not implementing (and it wouldn't have sense) an FTP client or server!
    Have you understood?
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

Similar Threads

  1. Socket Programming
    By keepStriving in forum Java Networking
    Replies: 8
    Last Post: January 23rd, 2014, 07:34 AM
  2. Java Socket Programming
    By varunkukreja24 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 17th, 2013, 11:34 PM
  3. Regarding socket programming
    By Dnyaneshwar in forum Java Networking
    Replies: 1
    Last Post: March 5th, 2013, 03:19 AM
  4. socket programming
    By advjava in forum Member Introductions
    Replies: 3
    Last Post: April 5th, 2011, 11:21 PM
  5. [SOLVED] Problem in socket programming
    By sinni in forum Java Networking
    Replies: 1
    Last Post: March 15th, 2011, 10:26 AM

Tags for this Thread