5 socat is a relay for bidirectional data transfer between two independent data
6 channels. Each of these data channels may be a file, pipe, device (serial line
7 etc. or a pseudo terminal), a socket (UNIX, IP4, IP6 - raw, UDP, TCP), an
8 SSL socket, proxy CONNECT connection, a file descriptor (stdin etc.), the GNU
9 line editor (readline), a program, or a combination of two of these.
10 These modes include generation of "listening" sockets, named pipes, and pseudo
13 socat can be used, e.g., as TCP port forwarder (one-shot or daemon), as an
14 external socksifier, for attacking weak firewalls, as a shell interface to UNIX
15 sockets, IP6 relay, for redirecting TCP oriented programs to a serial line, to
16 logically connect serial lines on different computers, or to establish a
17 relatively secure environment (su and chroot) for running client or server
18 shell scripts with network connections.
20 Many options are available to refine socats behaviour:
21 terminal parameters, open() options, file permissions, file and process owners,
22 basic socket options like bind address, advanced socket options like IP source
23 routing, linger, TTL, TOS (type of service), or TCP performance tuning.
25 More capabilities, like daemon mode with forking, client address check,
26 "tail -f" mode, some stream data processing (line terminator conversion),
27 choosing sockets, pipes, or ptys for interprocess communication, debug and
28 trace options, logging to syslog, stderr or file, and last but not least
29 precise error messages make it a versatile tool for many different purposes.
31 In fact, many of these features already exist in specialized tools; but until
32 now, there does not seem to exists another tool that provides such a generic,
33 flexible, simple and almost comprehensive (UNIX) byte stream connector.
39 before bothering with compilers, dependencies and include files, you might
40 try to get a binary distribution that matches your platform. Have a look at
41 the projects home page for actual information regarding socat binary
48 socat 1.7.0 was compiled and more or less successfully tested under the
49 following operating systems:
51 Debian lenny/sid on x86, kernel 2.6.24
55 OpenSolaris 10 on x86 with gcc
56 Mac OS X 10.5.5 on iMac G5, with libreadline
58 AIX 5.3 on 64bit Power4 with gcc
61 tests on Tru64 can no longer be performed because HP testdrive has taken down
64 Some versions of socat have been reported to successfully compile under older
65 Linux versions back to RedHat 2.1 (kernel 1.2.13, gcc 2.7.0), under AIX 4.1 and
66 4.3, SunOS 5.7-5.8, FreeBSD 4.2 - 4.9, MacOS X 10.1, Cygwin, Solaris 8 on x86,
67 OSR 5.0.6, NetBSD 1.6.1 and 2.0.2, OpenBSD 3.4 and 3.8, Tru64 5.1B, Mac OS X
68 10.1-10.2, and HP-UX 11
70 It might well compile and run under other UNIX like operating systems.
76 Get the tarball and extract it:
82 make install # installs socat, filan, and procan in /usr/local/bin
84 For compiling socat, gcc (or egc) is recommended.
85 If gcc is not available, the configure script will fail to determine
86 some features; then you'd better begin with one of the Makefiles and config.h's
87 from the Config directory.
89 If you have problems with the OpenSSL library, you can apply the option
90 "--disable-openssl" to configure.
92 If you have problems with the readline library or (n)curses, you can apply the
93 option "--disable-readline" to configure.
95 If you have problems with the tcp wrappers library, you can apply the option
96 "--disable-libwrap" to configure.
98 If you still get errors or a tremendous amount of warnings you can exclude
99 the features for system call tracing and file descriptor analyzing by
100 applying the options "--disable-sycls --disable-filan" to configure.
102 You still need the functions vsnprintf and snprintf that are in the GNU libc,
103 but might not be available with some proprietary libc's.
105 The configure script looks for headers and libraries of openssl, readline, and
106 tcp wrappers in the OS'es standard places and in the subdirectories include/
107 and lib/ of the following places:
112 and for openssl also in:
114 In case of unexpected behaviour it is important to understand that configure
115 first searches for the appropriate include file and then expects to find the
116 library in the associated lib directory. That means, when e.g. a OpenSSL
117 installation resides under /usr/local and there is a symbolic link from
118 /usr/include/ssl/ssl.h to /usr/local/ssl/include/ssl/ssl.h, configure will find
119 the /usr/include/... header and will therefore expect libssl in /usr/lib
120 instead of /usr/local/...
122 If configure does not find a header file or library but you know where it is,
123 you can specify additional search locations, e.g.:
124 export LIBS="-L$HOME/lib"
125 export CPPFLAGS="-I$HOME/include"
126 before running configure and make.
128 For other operating systems, if socat does not compile without errors, refer to
132 platform specifics - redhat
133 ---------------------------
135 On RedHat Linux 9.0, including openssl/ssl.h might fail due to problems with
136 the krb5-devel package. configure reacts with disabling openssl integration.
137 To solve this issue, help cpp to find the krb5.h include file:
138 CPPFLAGS="-I/usr/kerberos/include" ./configure
141 platform specifics - aix
142 ------------------------
144 The flock() prototype is not available but the function is. Thus, to enable the
145 socat flock options, run configure and then change in config.h the line
146 /* #undef HAVE_FLOCK */
149 and continue the build process.
151 When using the OpenSSL rpm provided by IBM, configure might need the
152 environment variable setting:
153 LIBS="-L/opt/freeware/lib"
155 When using the OpenSSL bundle provided by IBM, egd needs to be installed too
156 to get enough entropy.
158 socat compiles not only with gcc, but also with xlc. Just adapt the Makefile:
159 replace gcc by /usr/vac/bin/xlc and remove gcc specific options
160 "-Wall -Wno-parentheses".
162 When linking with the OpenSSL library provided by IBM, errors may occur:
163 ld: 0711-317 ERROR: Undefined symbol: .__umoddi3
164 In this case, you need to link with libgcc or compile libcrypt yourself using
165 xlc, or disable SSL (in config.h, undefine WITH_OPENSSL and recompile)
167 The score of test.sh can be improved by uncommenting MISCDELAY=1 in this
171 platform specifics - solaris
172 ----------------------------
174 If libreadline or libssl are in a directory not searched by the loader per
175 default, e.g. /opt/sfw/lib, you must add this directory to $LD_LIBRARY_PATH,
176 for running both configure and the socat executables, e.g.:
177 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sfw/lib
179 For some shell scripts, it is preferable to have /usr/xpg4/bin at a prominent
182 With the default compiler define _GNU_SOURCE, the CMSG_* macros are not
183 available, and therefore ancillary messages cannot be used. To enable these try
185 After running ./configure, edit Makefile and replace "-D_GNU_SOURCE" with
186 "-D_XPG4_2 -D__EXTENSIONS__" and run make
189 platform specifics - hp-ux
190 --------------------------
192 Ancillary messages cannot be compiled in with socat: both struct msghdr and
193 strutc cmsghdr are required. Compiling with -D_XOPEN_SOURCE_EXTENDED provides
194 struct msghdr but disables struct cmsghdr while -D_OPEN_SOURCE disables struct
195 msghdr but disables struct cmsghdr. Please contact socat development if you
198 Shutting down the write channel of a UNIX domain socket does not seem to
199 trigger an EOF on the peer socket. This makes problems with the exec and
202 This OS provides the type "long long", but not the strtoll() function to read
203 data into a long long variable.
205 UNIX domain sockets are only supported with SOCK_STREAM, not with datagrams
208 With UDP sockets it seems to happen that the select() call reports available
209 data (or EOF) but a subsequent read() call hangs.
212 platform specifics - tru64
213 --------------------------
215 When the use of the readline address fails with an error like:
216 socat: /sbin/loader: Fatal Error: Reference to unresolvable symbol "tgetent" in ".../libreadline.so.4"
217 and you still want to use shared libraries, try the following workaround:
218 $ make distclean; LIBS="-static" ./configure
219 remove the "-static" occurrence in Makefile
226 These files reside in the doc subdirectory:
228 socat.1 is the man page, socat.html is the HTML based man page. It is actual,
229 but describes only the more useful options.
231 xio.help is an older, but more exact description in text form; with socat
232 version 1.6.0 it is outdated.
234 doc/socat-openssltunnel.html is a simple tutorial for a private SSL connection.
235 doc/socat-multicast.html is a short tutorial for multicast and broadcast
237 doc/socat-tun shows how to build a virtual network between two hosts.
239 socat.1 and socat.html can be generated from socat.yo (which is released with
240 socat 1.6.0.1 and later) using the yodl document language package. Maintenance
241 of yodl had been discontinued by its author
242 (http://www.xs4all.nl/~jantien/yodl/) (there seems to be a revival at
243 http://yodl.sourceforge.net/ though). For socat, the old version 1.31 is used;
244 an rpm is still distributed with recent OpenSuSE versions (confirmed for
245 OpenSuSE 10.1 in suse/i586/yodl-1.31.18-1142.i586.rpm). It appears to install
246 smoothly also under RedHat Linux. After yodl 1.31 installation, the following
247 correction must be performed in /usr/share/yodl/shared.yo in two places:
248 < whenhtml(htmlcommand(<!)ARG1+htmlcommand(>)))
249 > whenhtml(htmlcommand(<!--)ARG1+htmlcommand(-->)))
255 socat is distributed under the terms of the GNU GPL;
256 except for install-sh, which is copyright MIT, with its own license;
258 In addition, as a special exception, the copyright holder
259 gives permission to link the code of this program with
260 any version of the OpenSSL library which is distributed
261 under a license identical to that listed in the included
262 COPYING.OpenSSL file, and distribute linked combinations
263 including the two. You must obey the GNU General Public
264 License in all respects for all of the code used other
265 than OpenSSL. If you modify this file, you may extend this
266 exception to your version of the file, but you are not
267 obligated to do so. If you do not wish to do so, delete
268 this exception statement from your version.
271 This program is free software; you can redistribute it and/or modify
272 it under the terms of the GNU General Public License as published by
273 the Free Software Foundation, version 2 of the License
275 This program is distributed in the hope that it will be useful,
276 but WITHOUT ANY WARRANTY; without even the implied warranty of
277 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
278 GNU General Public License for more details.
280 You should have received a copy of the GNU General Public License
281 along with this program; if not, write to the Free Software
282 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
288 For questions, bug reports, ideas, contributions etc. please contact
289 socat@dest-unreach.org
291 For socat source distribution, bug fixes, and latest news see
292 http://www.dest-unreach.org/socat/
294 www.socat.org is an alternate site providing the same contents.
296 public git repository:
297 git://repo.or.cz/socat.git
298 http://repo.or.cz/r/socat.git