You are not logged in.

#1 2013-02-11 17:55:51

juray
Member
Registered: 2012-01-12
Posts: 26

how to open tcp connection

Please help me, how to in ARch open tcp connection? My problem is that i dont have /dev/tcp device.

Thak you.

Offline

#2 2013-02-11 20:42:25

gsgleason
Member
Registered: 2012-10-08
Posts: 71

Re: how to open tcp connection

/dev/tcp is special in that way.  It's doesn't actually exist as a file, but still works only for redirection purposes.

From the man page of bash:

handles several filenames specially when they are used in redirec‐
       tions, as described in the following table:

              /dev/fd/fd
                     If  fd  is  a valid integer, file descriptor fd is dupli‐
                     cated.
              /dev/stdin
                     File descriptor 0 is duplicated.
              /dev/stdout
                     File descriptor 1 is duplicated.
              /dev/stderr
                     File descriptor 2 is duplicated.
              /dev/tcp/host/port
                     If host is a valid hostname or Internet address, and port
                     is  an integer port number or service name, bash attempts
                     to open a TCP connection to the corresponding socket.
              /dev/udp/host/port
                     If host is a valid hostname or Internet address, and port
                     is  an integer port number or service name, bash attempts
                     to open a UDP connection to the corresponding socket.

Examples:

http://thesmithfam.org/blog/2006/05/23/ … -devtcp-2/
http://hacktux.com/bash/socket

Offline

#3 2013-02-11 22:00:58

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,772

Re: how to open tcp connection

What are you trying to do?
Are you asking about firewalls?
Are you asking about how to provide a service such as HTTP, FTP, ssh, or (gulp) Telnet?
Are you asking about how to write a program that provides a service through a tcp port ?(how to write a server?)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2013-02-12 11:58:01

juray
Member
Registered: 2012-01-12
Posts: 26

Re: how to open tcp connection

Thaks for answers. i wanted to try these commands

exec 3<>/dev/tcp/bruxy.regnet.cz/80
echo -e "GET http://bruxy.regnet.cz/linux/mandel/mandel.ansi HTTP/1.0\n" >&3
cat <&3

This is the method how to download bash script from this page

http://bruxy.regnet.cz/web/linux/EN/man … t-in-bash/

But everywhere is mentioned this path of device

/dev/tcp

and i dont have it

$ls /dev/tcp
ls: cannot access /dev/tcp: No such file or directory
$cat /dev/tcp
cat: /dev/tcp: No such file or directory

Recently i have discovered this path in my system

$ls /proc/net/tcp
/proc/net/tcp

Is that same?

Offline

#5 2013-02-12 17:18:07

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,772

Re: how to open tcp connection

Okay, that all hurts my brain.  It would seem this /dev/tcp is no longer supported in the kernel; but --- it seems that Bash provides the functionality.  If you are using the Bash shell, what you propose should work. 
In fact... I just tried it in zsh, and it failed miserably.  Then I invoked it under Bash, and I am looking at a Madelbrot Fractal.

$ls /proc/net/tcp
/proc/net/tcp

Is that same?

No.
"Files" under the /proc tree are to provide information about what is going on inside the drivers.  Those files will provide information about retries, bit error rates, and other sundry information about the innards of the network operation.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2013-02-13 09:01:24

juray
Member
Registered: 2012-01-12
Posts: 26

Re: how to open tcp connection

oh ok! sorry i get it smile

/dev/tcp is not file in any way. bash can open tcp or udp connection through it and this is bash feature.

only for completeness bash has to be compiled with this

--enable-net-redirections
                          enable /dev/tcp/host/port redirection

thank you. problem solved smile

Offline

Board footer

Powered by FluxBB