Regarding Network devices - Linux

This is a discussion on Regarding Network devices - Linux ; Hi All, Like character and block devices have files in /dev directory which we can open, read from and write to, do network devices too have such files? if yes what are those files? if no, then how to open ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Regarding Network devices

  1. Regarding Network devices

    Hi All,
    Like character and block devices have files in /dev directory which we
    can open,
    read from and write to, do network devices too have such files? if yes
    what are those files?
    if no, then how to open the device for a read or write??

    Thanks in advance
    MAx


  2. Re: Regarding Network devices

    MAx wrote:
    > Hi All,
    > Like character and block devices have files in /dev directory which we
    > can open,
    > read from and write to, do network devices too have such files? if yes
    > what are those files?
    > if no, then how to open the device for a read or write??


    No, you cannot open/read/write/close a network device.
    You can open/read/write/close a network connection using a network
    device, though, and the "open" is a tad more complicated than just
    calling "open(...)":

    Although networking can be on a peer-to-peer basis, most is
    client/server based:
    Server: socket()/bind()/listen()/accept()/read()/write()
    Client: socket()/connect()/read()/write()
    (this is for TCP/IP).

    If you want to do network programming, get e.g. Richard Stevens' "Unix
    Network Programming".

    NB Some bash implementations allow to redirect stdin/stdout from/to
    /dev/tcp//, but these are not real devices but rather
    pseudo-devices detected by bash, i.e. the *only* work with redirection!

    Josef
    --
    These are my personal views and not those of Fujitsu Siemens Computers!
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize (T. Pratchett)
    Company Details: http://www.fujitsu-siemens.com/imprint.html


  3. Re: Regarding Network devices

    On Oct 1, 6:58 pm, MAx wrote:
    > Hi All,
    > Like character and block devices have files in /dev directory which we
    > can open,
    > read from and write to, do network devices too have such files? if yes
    > what are those files?
    > if no, then how to open the device for a read or write??
    >
    > Thanks in advance
    > MAx


    If you are looking for a simple solution to write binary data over a
    network, try netcat.
    man nc

    http://www.openbsd.org/cgi-bin/man.cgi?query=nc

    It does NOT open the network interface like a file (because to do that
    you need to take care of multiple network layers) but opens specified
    ports for reading and writing to like a file. So you can transfer a
    file from A to B using the following
    At B:
    nc -l -p 2222 >myfile.txt

    At A:
    nc destination.com 2222
    >From memory, I dont think the transmitting side exits nc after it has

    finished.


+ Reply to Thread