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.
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.
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.
Cross posted here.
sumit.tejas02 (January 15th, 2014)
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.net — SCJP 5 (91%) – SCWCD 5 (94%)
Useful links for Java beginners – My new project Java Examples on Google Code
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 ?
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.net — SCJP 5 (91%) – SCWCD 5 (94%)
Useful links for Java beginners – My new project Java Examples on Google Code