Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am porting C/pro*c code from UNIX to Linux. The code is:

#define __NFDBIT       (8 * sizeof(unsigned long))
#define __FD_SETSIZ    1024
typedef struct {
    unsigned long fds_bits [__FDSET_LONG];
} __ernel_fd_set;

typedef __ernel_fd_set           fd_set_1;
int main()
    fd_set_1 listen_set;
    int listen_sd;
    int socket_id;
    socket_id = t_open("/dev/tcp", O_RDWR|O_NONBLOCK, (struct t_info *) 0);
    if ( socket_id <0 )
    return 0;

In UNIX the value of socket_id is > 0 in Linux it is -1. Reason is in UNIX, there is a /dev/tcp. This is not present on Linux. Also in UNIX this tcp file is character special file which is different from normal file.

Is there any way to create same character special file in Linux as in UNIX or how to proceed this further?

share|improve this question
Is there a reason why you do not use Berkeley sockets/POSIX sockets? – jofel May 16 '12 at 11:16
yes Jofel. In that case I need to modify large amount of existing code which is not feasible. I'am looking for replacement of /dev/tcp in Linux or how it should be created in Linux to make it work as in Unix. Following are information about /dev/tcp in Unix. – smileybhuff May 16 '12 at 11:27
How do you compile your software? AFAIK on Linux, XTI/TLI is only supported by some extra libraries like Linux Fast Stream from OpenSS7 or emulators like iBCS. There is no way to simply create /dev/tcp on Linux. You may find /dev/tcp used from bash, but in this case it is just a relict which tells bash to open a tcp socket. The device does not really exists. – jofel May 16 '12 at 11:43
cc tet.o -o test-L$ORACLE_HOME/lib64 -lxnet executed binary file test There is a way to create character file tcp under /dev using command mknod tcp c <x> <y> . In unix the device entries for tcp are 42,2. that is file command (file /dev/tcp) shows "character special (42/2)" where x = 42 and y =2. But with same entries I created in Linux as mknod tcp c 42 2.again socket_id is -1. Here the problem is device entries to be used Linux. – smileybhuff May 16 '12 at 11:57
@smilebhuff It is not enough to create the node, someone in the kernel must be responsible for it - which is not the case under Linux. – glglgl May 16 '12 at 12:01
up vote 14 down vote accepted

t_open() and its associated /dev/tcp and such are part of the TLI/XTI interface, which lost the battle for TCP/IP APIs to BSD sockets.

On Linux, there is a /dev/tcp of sorts. It isn't a real file or kernel device. It's something specially provided by Bash, and it exists only for redirections. This means that even if one were to create an in-kernel /dev/tcp facility, it would be masked in interactive use 99%[*] of the time by the shell.

The best solution really is to switch to BSD sockets. Sorry.

You might be able to get the strxnet XTI emulation layer to work, but you're better off putting your time into getting off XTI. It's a dead API, unsupported not just on Linux, but also on the BSDs, including OS X.

(By the way, the strxnet library won't even build on the BSDs, because it depends on LiS, a component of the Linux kernel. It won't even configure on a stock BSD or OS X system, apparently because it also depends on GNU sed.)

[*] I base this wild guess on the fact that Bash is the default shell for non-root users in all Linux distros I've used. You therefore have to go out of your way on Linux, as a rule, to get something other than Bash.

share|improve this answer
Warren thanks for your inputs. Sorry I'am very new to these socket programming and API concepts. Please bare with my questions. What do you mean by " strxnet XTI emulation latyer" we recently installed one of the packages of strxnet (strxnet- to get some of openss7 libraries/headerfiles.What can I do more with that? – smileybhuff May 16 '12 at 12:43
I've never used it myself, but from a quick examination of the tarball, it looks like once it's installed, it provides an XTI emulation layer. You should just be able to point your compiler at it with -I and -L flags and expect it to work. But if it does not, I wouldn't throw a lot of time at it. – Warren Young May 16 '12 at 12:49
I know about -I and -L which is to include headers/libraries respectively. But what exactly I have to do here with -I / -L? sorry again if my question is wrong. – smileybhuff May 16 '12 at 12:53
That depends on where the package installed the files. Find the library file, libstrxnet.so.*: that directory is what you pass to -L. Find xti.h: pass that directory to -I. You will also need -lstrxnet at minimum. Bottom line: see the strxnet docs. – Warren Young May 16 '12 at 13:00
Warren, that is what I have done during compilation. please see the steps I gave in previous command. This library has t_open() function. But problem is not with this function. Problem is with /dev/tcp which t_open is trying to open. – smileybhuff May 16 '12 at 13:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.