Help to create Sockets from scratch

Hi,

I want to write my own implementation of Sockets in C from scratch (Not AF_INET or any other pre-defined library socket). Can you please help me ?

Thanking you,
modshah

Comments

  • : Hi,
    :
    : I want to write my own implementation of Sockets in C from scratch (Not AF_INET or any other pre-defined library socket). Can you please help me ?
    :
    : Thanking you,
    : modshah
    :

    Why re-invent the wheel?



    [italic][blue]To understand recursive, first you need to understand recursive[/blue][/italic]

  • [b][red]This message was edited by stober at 2003-6-29 12:48:33[/red][/b][hr]
    : Hi,
    :
    : I want to write my own implementation of Sockets in C from scratch (Not AF_INET or any other pre-defined library socket). Can you please help me ?
    :
    : Thanking you,
    : modshah
    :
    [blue]After 10-15 years you might be able to accomplish that -- but by then it will be obsolete because computers as we know them today will not exist.

    Even if you did manage to accomplish it in a short timeframe, your program(s) would not be able to communicate with anyone else in the world because of your non-standard socket protocol.
    [/blue]


  • : Hi,
    :
    : I want to write my own implementation of Sockets in C from scratch (Not AF_INET or any other pre-defined library socket). Can you please help me ?
    :
    : Thanking you,
    : modshah
    :

    Not AF_INET? You mean you dont want to use TCP/P and want to create network protocols too? Uuhh..

    The idea of socket-library isn't very complex. An API that offers sockets and functions to handle them. Hard part is to make efficient algorithms to achieve this. You need to keep track of every socket your library has opened and this means large data structures.

    Okay, that's the "upper part" of library that is shown to user. Then comes the network part. I don't know how other operating systems does this so I use Windows as an example. Windows has socket-driver sitting in top of network stack. When user opens socket and sends data through it, ws2_32.dll catches that data and transfers it to kernel-driver (don't know it's name). Then kernel-driver transfers packet to TCP-driver, which hands it over to IP-driver (to be exact, they are the same driver), which hands it over to network driver. Those drivers uses another driver called NDIS to bounce the packet around.

    Now if you want to make the whole s**t by yourself there's a hell lot of work to do. You would have to create driver, which handles your API's calls, wraps packets into nice headers (which are wrapped into medium-header like Ethernet). Then you would have to somehow attach it to underlying NIC-driver. When this is done you have to create IOCTL-message handler for communicating with the user space module.

    But if you stick with the TCP/IP and just create your own socket-library things will become a little more easier. Not much but a little :)
  • : : Hi,
    : :
    : : I want to write my own implementation of Sockets in C from scratch (Not AF_INET or any other pre-defined library socket). Can you please help me ?
    : :
    : : Thanking you,
    : : modshah
    : :
    :
    : Not AF_INET? You mean you dont want to use TCP/P and want to create network protocols too? Uuhh..
    :
    : The idea of socket-library isn't very complex. An API that offers sockets and functions to handle them. Hard part is to make efficient algorithms to achieve this. You need to keep track of every socket your library has opened and this means large data structures.
    :
    : Okay, that's the "upper part" of library that is shown to user. Then comes the network part. I don't know how other operating systems does this so I use Windows as an example. Windows has socket-driver sitting in top of network stack. When user opens socket and sends data through it, ws2_32.dll catches that data and transfers it to kernel-driver (don't know it's name). Then kernel-driver transfers packet to TCP-driver, which hands it over to IP-driver (to be exact, they are the same driver), which hands it over to network driver. Those drivers uses another driver called NDIS to bounce the packet around.
    :
    : Now if you want to make the whole s**t by yourself there's a hell lot of work to do. You would have to create driver, which handles your API's calls, wraps packets into nice headers (which are wrapped into medium-header like Ethernet). Then you would have to somehow attach it to underlying NIC-driver. When this is done you have to create IOCTL-message handler for communicating with the user space module.
    :
    : But if you stick with the TCP/IP and just create your own socket-library things will become a little more easier. Not much but a little :)
    :


    Dear friend,

    I didn't mean to say that I didn't want to implement TCP/IP(Actually I want to be compliant). The real reason I want to write Sockets from scratch is this : I am developing my own operating system. So I cann't use other library code(atleast thats what I think). So can you please help me ? Any suggesions welcome.

    Thanks
  • :
    : Dear friend,
    :
    : I didn't mean to say that I didn't want to implement TCP/IP(Actually I want to be compliant). The real reason I want to write Sockets from scratch is this : I am developing my own operating system. So I cann't use other library code(atleast thats what I think). So can you please help me ? Any suggesions welcome.
    :
    : Thanks
    :

    Oh, ok. Well I explained the principle (in very common level). Look at linux or BSD sources and see how it is done there. I think there are some pretty generic stuff which can be easily ported to other systems. Or if you don't want port it at least you get a closer look how things work.

    But unfortunatelly my knowledge about this isn't very good so I can't help you with this.
  • Thanks weicco.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories