mirror of
https://repo.or.cz/socat.git
synced 2025-07-27 13:02:57 +00:00
ported generic socket to *BSD; minor improvements
This commit is contained in:
parent
8947cc92dc
commit
13b73776e7
37 changed files with 1441 additions and 258 deletions
22
xio-listen.c
22
xio-listen.c
|
@ -83,6 +83,9 @@ int
|
|||
|
||||
/* waits for incoming connection, checks its source address and port. Depending
|
||||
on fork option, it may fork a subprocess.
|
||||
pf specifies the syntax expected for range option. In the case of generic
|
||||
socket it is 0 (expcting raw binary data), and the real pf can be obtained
|
||||
from us->af_family; for other socket types pf == us->af_family
|
||||
Returns 0 if a connection was accepted; with fork option, this is always in
|
||||
a subprocess!
|
||||
Other return values indicate a problem; this can happen in the master
|
||||
|
@ -119,9 +122,9 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
|
|||
xiosetchilddied(); /* set SIGCHLD handler */
|
||||
}
|
||||
|
||||
if ((xfd->fd = Socket(pf, socktype, proto)) < 0) {
|
||||
if ((xfd->fd = Socket(us->sa_family, socktype, proto)) < 0) {
|
||||
Msg4(level,
|
||||
"socket(%d, %d, %d): %s", pf, socktype, proto, strerror(errno));
|
||||
"socket(%d, %d, %d): %s", us->sa_family, socktype, proto, strerror(errno));
|
||||
return STAT_RETRYLATER;
|
||||
}
|
||||
|
||||
|
@ -161,15 +164,10 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
|
|||
}
|
||||
#endif /* WITH_UNIX */
|
||||
|
||||
retropt_int(opts, OPT_BACKLOG, &backlog);
|
||||
if (Listen(xfd->fd, backlog) < 0) {
|
||||
Error3("listen(%d, %d): %s", xfd->fd, backlog, strerror(errno));
|
||||
return STAT_RETRYLATER;
|
||||
}
|
||||
|
||||
#if WITH_IP4 /*|| WITH_IP6*/
|
||||
if (retropt_string(opts, OPT_RANGE, &rangename) >= 0) {
|
||||
if (parserange(rangename, us->sa_family, &xfd->para.socket.range) < 0) {
|
||||
if (xioparserange(rangename, pf, &xfd->para.socket.range)
|
||||
< 0) {
|
||||
free(rangename);
|
||||
return STAT_NORETRY;
|
||||
}
|
||||
|
@ -189,6 +187,12 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
|
|||
retropt_bool(opts, OPT_LOWPORT, &xfd->para.socket.ip.lowport);
|
||||
#endif /* WITH_TCP || WITH_UDP */
|
||||
|
||||
retropt_int(opts, OPT_BACKLOG, &backlog);
|
||||
if (Listen(xfd->fd, backlog) < 0) {
|
||||
Error3("listen(%d, %d): %s", xfd->fd, backlog, strerror(errno));
|
||||
return STAT_RETRYLATER;
|
||||
}
|
||||
|
||||
if (xioopts.logopt == 'm') {
|
||||
Info("starting accept loop, switching to syslog");
|
||||
diag_set('y', xioopts.syslogfac); xioopts.logopt = 'y';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue