3 socat is a relay for bidirectional data transfer between two independent data
4 channels. Each of these data channels may be a file, pipe, device (serial line
5 etc. or a pseudo terminal), a socket (UNIX, IP4, IP6 - raw, UDP, TCP), an
6 SSL socket, proxy CONNECT connection, a file descriptor (stdin etc.), the GNU
7 line editor (readline), a program, or a combination of two of these.
8 These modes include generation of "listening" sockets, named pipes, and pseudo
11 socat can be used, e.g., as TCP port forwarder (one-shot or daemon), as an
12 external socksifier, for attacking weak firewalls, as a shell interface to UNIX
13 sockets, IP6 relay, for redirecting TCP oriented programs to a serial line, to
14 logically connect serial lines on different computers, or to establish a
15 relatively secure environment (su and chroot) for running client or server
16 shell scripts with network connections.
18 Many options are available to refine socats behaviour:
19 terminal parameters, open() options, file permissions, file and process owners,
20 basic socket options like bind address, advanced socket options like IP source
21 routing, linger, TTL, TOS (type of service), or TCP performance tuning.
23 More capabilities, like daemon mode with forking, client address check,
24 "tail -f" mode, some stream data processing (line terminator conversion),
25 choosing sockets, pipes, or ptys for interprocess communication, debug and
26 trace options, logging to syslog, stderr or file, and last but not least
27 precise error messages make it a versatile tool for many different purposes.
29 In fact, many of these features already exist in specialized tools; but until
30 now, there does not seem to exists another tool that provides such a generic,
31 flexible, simple and almost comprehensive (UNIX) byte stream connector.
35 before bothering with compilers, dependencies and include files, you might
36 try to get a binary distribution that matches your platform. Have a look at
37 the projects home page for actual information regarding socat binary
42 socat 1.8.0.1 was compiled and more or less successfully tested under the
43 following operating systems:
48 OpenIndiana 2021-04 on i386 with gcc
52 Cygwin 3.5.3 (from Windows 10, 11 & Servers)
56 Get the tarball and extract it :
64 make install # installs socat, filan, and procan in /usr/local/bin
67 For compiling socat, gcc (or clang) is recommended.
68 If gcc (or a compiler with similar front end) is not available, the configure
69 script might fail to determine some features
71 If you have problems with the OpenSSL library, you can apply the option
72 "--disable-openssl" to configure.
74 If you have problems with the readline library or (n)curses, you can apply the
75 option "--disable-readline" to configure.
77 If you have problems with the tcp wrappers library, you can apply the option
78 "--disable-libwrap" to configure.
80 If you still get errors or a tremendous amount of warnings you can exclude
81 the features for system call tracing and file descriptor analyzing by
82 applying the options "--disable-sycls --disable-filan" to configure.
84 You still need the functions vsnprintf and snprintf that are in the GNU libc,
85 but might not be available with some proprietary libc's.
87 The configure script looks for headers and libraries of openssl, readline, and
88 tcp wrappers in the OS'es standard places and in the subdirectories include/
89 and lib/ of the following places:
94 and for openssl also in:
96 In case of unexpected behaviour it is important to understand that configure
97 first searches for the appropriate include file and then expects to find the
98 library in the associated lib directory. That means, when e.g. a OpenSSL
99 installation resides under /usr/local and there is a symbolic link from
100 /usr/include/ssl/ssl.h to /usr/local/ssl/include/ssl/ssl.h, configure will find
101 the /usr/include/... header and will therefore expect libssl in /usr/lib
102 instead of /usr/local/...
104 If configure does not find a header file or library but you know where it is,
105 you can specify additional search locations, e.g.:
106 export LIBS="-L$HOME/lib"
107 export CPPFLAGS="-I$HOME/include"
108 before running configure and make.
110 For other operating systems, if socat does not compile without errors, refer to
113 ## platform specifics - Debian (Ubuntu, ...)
117 ## platform specifics - redhat
119 Install the following packages before building socat:
124 On RedHat Linux 9.0, including openssl/ssl.h might fail due to problems with
125 the krb5-devel package. configure reacts with disabling openssl integration.
126 To solve this issue, help cpp to find the krb5.h include file:
127 CPPFLAGS="-I/usr/kerberos/include" ./configure
129 ## platform specifics - aix
131 The flock() prototype is not available but the function is. Thus, to enable the
132 socat flock options, run configure and then change in config.h the line
135 *#define HAVE_FLOCK 1*
136 and continue the build process.
138 When using the OpenSSL rpm provided by IBM, configure might need the
139 environment variable setting:
140 LIBS="-L/opt/freeware/lib"
142 When using the OpenSSL bundle provided by IBM, egd needs to be installed too
143 to get enough entropy.
145 socat compiles not only with gcc, but also with xlc. Just adapt the Makefile:
146 replace gcc by /usr/vac/bin/xlc and remove gcc specific options
147 "-Wall -Wno-parentheses".
149 When linking with the OpenSSL library provided by IBM, errors may occur:
150 ld: 0711-317 ERROR: Undefined symbol: .__umoddi3
151 In this case, you need to link with libgcc or compile libcrypt yourself using
152 xlc, or disable SSL (in config.h, undefine WITH_OPENSSL and recompile)
154 The score of test.sh can be improved by uncommenting MISCDELAY=1 in this
157 ## platform specifics - solaris
159 If libreadline or libssl are in a directory not searched by the loader per
160 default, e.g. /opt/sfw/lib, you must add this directory to $LD_LIBRARY_PATH,
161 for running both configure and the socat executables, e.g.:
162 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sfw/lib
164 For some shell scripts, it is preferable to have /usr/xpg4/bin at a prominent
167 With the default compiler define *_GNU_SOURCE*, the CMSG_* macros are not
168 available, and therefore ancillary messages cannot be used. To enable these try
170 After running ./configure, edit Makefile and replace "-D_GNU_SOURCE" with
171 "-D_XPG4_2 -D__EXTENSIONS__" and run make
173 ## platform specifics - hp-ux
175 Ancillary messages cannot be compiled in with socat: both struct msghdr and
176 struct cmsghdr are required. Compiling with -D_XOPEN_SOURCE_EXTENDED provides
177 struct msghdr but disables struct cmsghdr while -D_OPEN_SOURCE disables struct
178 msghdr but disables struct cmsghdr. Please contact socat development if you
181 Shutting down the write channel of a UNIX domain socket does not seem to
182 trigger an EOF on the peer socket. This makes problems with the exec and
185 This OS provides the type "long long", but not the strtoll() function to read
186 data into a long long variable.
188 UNIX domain sockets are only supported with SOCK_STREAM, not with datagrams
191 With UDP sockets it seems to happen that the select() call reports available
192 data (or EOF) but a subsequent read() call hangs.
194 ## platform specifics - tru64
196 When the use of the readline address fails with an error like:
197 socat: /sbin/loader: Fatal Error: Reference to unresolvable symbol "tgetent" in ".../libreadline.so.4"
198 and you still want to use shared libraries, try the following workaround:
199 $ make distclean; LIBS="-static" ./configure
200 remove the "-static" occurrence in Makefile
205 These files reside in the doc subdirectory:
207 socat.1 is the man page, socat.html is the HTML based man page. It is actual,
208 but describes only the more useful options.
210 doc/socat-openssltunnel.html is a simple tutorial for a private SSL connection.
211 doc/socat-multicast.html is a short tutorial for multicast and broadcast
213 doc/socat-tun shows how to build a virtual network between two hosts.
215 socat.1 and socat.html can be generated from socat.yo (which is released with
216 socat 1.6.0.1 and later) using the yodl document language package. Maintenance
217 of yodl had been discontinued by its author
218 (<http://www.xs4all.nl/~jantien/yodl/>) (there seems to be a revival at
219 <http://yodl.sourceforge.net/> though). For socat, the revival version 3.03 is used,
223 socat is distributed under the terms of the GNU GPLv2;
224 except for install-sh, which is copyright MIT, with its own license;
226 In addition, as a special exception, the copyright holder
227 gives permission to link the code of this program with
228 any version of the OpenSSL library which is distributed
229 under a license identical to that listed in the included
230 COPYING.OpenSSL file, and distribute linked combinations
231 including the two. You must obey the GNU General Public
232 License in all respects for all of the code used other
233 than OpenSSL. If you modify this file, you may extend this
234 exception to your version of the file, but you are not
235 obligated to do so. If you do not wish to do so, delete
236 this exception statement from your version.
239 This program is free software ; you can redistribute it and/or
240 modify it under the terms of the GNU General Public License as
241 published by the Free Software Foundation, version 2 of the License.
243 This program is distributed in the hope that it will be useful,
244 but WITHOUT ANY WARRANTY; without even the implied warranty of
245 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
246 GNU General Public License for more details.
248 You should have received a copy of the GNU General Public License
249 along with this program; if not, write to the Free Software
250 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
255 For questions, bug reports, ideas, contributions etc. please contact
256 <socat@dest-unreach.org>
258 For socat source distribution, bug fixes, and latest news see
259 <http://www.dest-unreach.org/socat/>
261 <www.socat.org> is an alternate site providing the same contents.
263 public git repository:
264 git://repo.or.cz/socat.git
265 <http://repo.or.cz/socat.git>