Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Networks - alternative to sockets?

  1. Aug 21, 2006 #1
    Hey guys just nusy writing out a server and client program in Java.
    i use sockets to transfer data from one program to another..

    just wanted to know if there is an alternative to newtorked communication between client and server apart from using sockets.

    also ...where do sockets fit in the OSI 7 model layer...???


  2. jcsd
  3. Aug 21, 2006 #2
    Layer 4, is where ports/sockets fit in the osi model. Although IP doesnt fit directly to the osi model, tcp sits at the transport layer (also udp and rtp).


    There are lots of protocols you could write code to use, one is actually osi, the only problem with using a different protocol is that the client and server would have to understand these protocols, ie have the protocol stack loaded on the nic of the two stations.
  4. Aug 21, 2006 #3
    Anttech>>thanks - still slightly confused about your last statement...is this an alternative to using sockets???
  5. Aug 21, 2006 #4
    Sockets/Ports are used by TCP/UDP sessions. Which is part of the IP protocol stack. So if you do not want to issue service requests to the network layer using ports, you will have to use a different protocol than IP. Such as OSI, or DECnet. But if you want to use a different networking protocol as your communications channel the client and server will have to be able to understand that protocol.
  6. Aug 21, 2006 #5


    User Avatar
    Science Advisor

    Ports and sockets are implemented by the Operating System. Sockets are an interface provided by the OS and ports are used to address an application. All of the communication sent through the sockets is eventually sent via TCP or UDP, over IP.
    Network Communication without the use of Ports can't use the common TCP or UDP transports since these protocols require, besides an IP address, a Port number, used to identify the application to which to deliver the data, but i don't see why you can't use IP (Anttech, why?).
    The IP packet's header contains only source/destination IPs, options, data, and fields such as TTL, Checksum, flags, etc.
    Possibly then you might create your own transport protocol, "ADP". This protocol uses some form to address applications, other than port number, and you provide the Operating System with an interface for sending and receiving ADP/IP packets.
    When sending data over the network your Operating System would place the data in an ADP packet and place the packet in the data field of one or more IP frames which would be moved down and onto the end host.
    The problem that i see would be packaging/unpackaging of packets which is not a problem as long as you use IP. I think that TCP/UDP packaging is done by the OS.
    Last edited: Aug 21, 2006
  7. Aug 22, 2006 #6
    Well you can, if you want to use a different transport layer protocol, but AFAIK only tcp and udp are implemented as the defacto standard on servers and clients as the transport layer protocol within the IP stack.
    Sure, if you really want to you can create your own layer 4 transport protocol. Consequently you will have to also write your app with this in mind, and probably you will have to write your own protocol stack from the Application layer down to your new protocol sitting on top of IP. To add to this your would have to then Hard write this new protocol to your network card so the network card can decapsulate packets correctly (May be wrong here.. cant remember), to be handed off to your application.


    I Believe TCP encapsulation is done by the Nic, not by the OS, The OS hands a stream of data to the transport layer, which divides this stream into segments (then --> packets --> frames and finally physical signal)

    Anyway why would you want to do this? It would be far easier to just change the protocol stack, wouldnt it?
    Last edited: Aug 22, 2006
  8. Aug 22, 2006 #7


    User Avatar
    Science Advisor

    Well, i think TCP is handed by the OS. I remember things like the TCP window size, congestion avoidance, etc..., and i don't see the NIC doing these things. At least early TCP implementations weren't on the NIC i bet. If this is true then you can avoid ports and sockets completely through code (code a part of the OS on the server & client).
    I think the advantage would be increased security, though it's nothing very feasible. You could also use this, possibly, to disrupt communications. If can fake TCP segments then i might flood the network with ACK/NACK packets for example. That would be cool. :smile:

    Actually, you know what, i remember wanting to try to fake ACK/NACKs and needing a NIC that allows me to put the TCP segments together myself. So i suppose TCP encapsulation is done at the NIC. :(
    Last edited: Aug 22, 2006
  9. Aug 22, 2006 #8
    I think you are right, The NIC only cares about Layer 1 and 2, layer 3 and 4 are done on the OS in kernal space (It is done on hardware with routers/Firewalls but on with Workstations/servers)... Guess you were correct. It makes sence when you think about it, because we are the ones who load the Protocol Stack on the OS, and can unload it if we want.

    There is a way to avoid windows sockets and ports by using 'raw sockets' however (obviously as it is) YOU as the app writer have to do the encapsulation of streams into packets etc on your own

  10. Aug 22, 2006 #9

    Hi LM741,

    If you're interested in other ways to allow multiple java apps to communicate (than writing your own protocol), you should try JMS or it's serverless alternative, Mantaray MQ. :)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook