IP mapped to tty port

This is a discussion on IP mapped to tty port within the Linux Programming forums, part of the Platform Specific Boards category; Does someone know a tool to map an IP address to a tty? I've to connect a device which communicate ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    35

    IP mapped to tty port

    Does someone know a tool to map an IP address to a tty?
    I've to connect a device which communicate through RS232 port and connected to a server which can open a socket. So I need a tool that receive from the running application, a TCP/IP packet and translate it to a raw data and sent it to/ a tty port.
    Every raw data received from the tty, the tool have to pack it in a tcp/ip packet and send it to the running application which has opened the socket...
    Does exists a such (freeware!) tool?
    Thanks in advance,
    Lollo
    PS: excuse me for my poor english!

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,270
    Seems like you could do this with netcat. You might have to write a little wrapper that throws the TTY into raw mode before passing the fd over to netcat, depending on your application.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    Registered User
    Join Date
    Jan 2008
    Posts
    35

    Unhappy

    Excuse me but I'm very newbie in linux programming... infact I don't understand how both programs proposed (by cornedbee e brewbook) can "redirect" the data extracted from the tcp packet to tty...

  5. #5
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,270
    Quote Originally Posted by lollobrigido View Post
    Excuse me but I'm very newbie in linux programming... infact I don't understand how both programs proposed (by cornedbee e brewbook) can "redirect" the data extracted from the tcp packet to tty...
    Both netcat and tcpserver listen on a socket. When a client connects, all data send by the client is directed to a file or device. Similarly, any data read from the device is sent back to the client. Sounds like basically what you need.

    Netcat simply redirects the input to standard output. So to connect the socket to the device, you simply redirect netcat into the device:

    Code:
    nc -l 9919  > /dev/tty
    In practice you would need to place the tty into the proper mode. You might do this with a smaller wrapper program, say, "initty":

    Code:
    nc -l 9919 | initty /dev/tty
    Or something like it.

    Netcat only supports one-way communication as far as I know. tcpserver may be more full-featured, but I have not used it.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    tcpserver is full-duplex, as some of the alternatives listed on the site I linked.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    35
    Great! tomorrow I try ... !!!
    This is the best support I've never experienced!!! leaving the "femto"$oft world everythings seems possible :-))))

    Thanks,
    Lollo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 02-08-2009, 04:30 PM
  2. FTP program
    By jakemott in forum Linux Programming
    Replies: 14
    Last Post: 10-06-2008, 02:58 PM
  3. get IP address and port of incoming connection
    By Elkvis in forum Linux Programming
    Replies: 4
    Last Post: 03-31-2008, 04:07 PM
  4. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 06:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21