support SCTP in addition to TCP
parent
89b88f036d
commit
b4469f1ed8
@ -0,0 +1,26 @@
|
||||
.TH socket_sctp4 3
|
||||
.SH NAME
|
||||
socket_sctp4 \- create a non-blocking SCTP/IP stream socket
|
||||
.SH SYNTAX
|
||||
.B #include <socket.h>
|
||||
|
||||
int \fBsocket_sctp4\fP();
|
||||
.SH DESCRIPTION
|
||||
socket_sctp4 creates a non-blocking SCTP/IP stream socket and returns a
|
||||
file descriptor pointing to that socket. If something goes wrong,
|
||||
socket_sctp4 returns -1, setting errno appropriately, without allocating
|
||||
any resources.
|
||||
|
||||
.SH EXAMPLE
|
||||
#include <socket.h>
|
||||
|
||||
int \fIs\fR;
|
||||
char \fIip\fR[4];
|
||||
uint16 \fIp\fR;
|
||||
|
||||
\fIs\fR = socket_sctp4();
|
||||
socket_bind4(s,ip,p);
|
||||
socket_connect4(s,ip,p);
|
||||
|
||||
.SH "SEE ALSO"
|
||||
socket_sctp4b(3), socket_bind4(3), socket_bind6(3)
|
@ -0,0 +1,10 @@
|
||||
#include <unistd.h>
|
||||
#include "socket.h"
|
||||
#include "ndelay.h"
|
||||
|
||||
int socket_sctp4(void) {
|
||||
int s=socket_sctp4b();
|
||||
if (s==-1) return -1;
|
||||
if (ndelay_on(s) == -1) { close(s); return -1; }
|
||||
return s;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
.TH socket_sctp4b 3
|
||||
.SH NAME
|
||||
socket_sctp4b \- create a blocking SCTP/IP stream socket
|
||||
.SH SYNTAX
|
||||
.B #include <socket.h>
|
||||
|
||||
int \fBsocket_sctp4b\fP();
|
||||
.SH DESCRIPTION
|
||||
socket_sctp4b creates a blocking SCTP/IP stream socket and returns a
|
||||
file descriptor pointing to that socket. If something goes wrong,
|
||||
socket_sctp4b returns -1, setting errno appropriately, without allocating
|
||||
any resources.
|
||||
|
||||
.SH EXAMPLE
|
||||
#include <socket.h>
|
||||
|
||||
int \fIs\fR;
|
||||
char \fIip\fR[4];
|
||||
uint16 \fIp\fR;
|
||||
|
||||
\fIs\fR = socket_sctp4b();
|
||||
socket_bind4(s,ip,p);
|
||||
socket_connect4(s,ip,p);
|
||||
|
||||
.SH "SEE ALSO"
|
||||
socket_sctp4(3), socket_bind4(3), socket_bind6(3)
|
@ -0,0 +1,26 @@
|
||||
#include <sys/types.h>
|
||||
#ifndef __MINGW32__
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include "windoze.h"
|
||||
#include "socket.h"
|
||||
#include "ndelay.h"
|
||||
|
||||
#ifndef EPROTONOSUPPORT
|
||||
#define EPROTONOSUPPORT EINVAL
|
||||
#endif
|
||||
|
||||
int socket_sctp4b(void) {
|
||||
#ifdef IPPROTO_SCTP
|
||||
int s;
|
||||
__winsock_init();
|
||||
s = winsock2errno(socket(PF_INET,SOCK_STREAM,IPPROTO_SCTP));
|
||||
if (s == -1) return -1;
|
||||
return s;
|
||||
#else
|
||||
errno=EPROTONOSUPPORT;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
.TH socket_sctp6 3
|
||||
.SH NAME
|
||||
socket_sctp6 \- create a non-blocking IPv6 SCTP/IP stream socket
|
||||
.SH SYNTAX
|
||||
.B #include <socket.h>
|
||||
|
||||
int \fBsocket_sctp6\fP();
|
||||
.SH DESCRIPTION
|
||||
socket_sctp6 creates a non-blocking IPv6 SCTP/IP stream socket and returns a
|
||||
file descriptor pointing to that socket. If something goes wrong,
|
||||
socket_sctp6 returns -1, setting errno appropriately, without allocating
|
||||
any resources.
|
||||
|
||||
.SH EXAMPLE
|
||||
#include <socket.h>
|
||||
|
||||
int \fIs\fR;
|
||||
char \fIip\fR[16];
|
||||
uint16 \fIp\fR;
|
||||
|
||||
\fIs\fR = socket_sctp6();
|
||||
socket_bind6(s,ip,p);
|
||||
socket_connect6(s,ip,p,0);
|
||||
|
||||
.SH "SEE ALSO"
|
||||
socket_bind4(3), socket_bind6(3)
|
@ -0,0 +1,10 @@
|
||||
#include <unistd.h>
|
||||
#include "socket.h"
|
||||
#include "ndelay.h"
|
||||
|
||||
int socket_sctp6(void) {
|
||||
int s=socket_sctp6b();
|
||||
if (s==-1) return -1;
|
||||
if (ndelay_on(s) == -1) { close(s); return -1; }
|
||||
return s;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
.TH socket_sctp6b 3
|
||||
.SH NAME
|
||||
socket_sctp6b \- create a blocking IPv6 SCTP/IP stream socket
|
||||
.SH SYNTAX
|
||||
.B #include <socket.h>
|
||||
|
||||
int \fBsocket_sctp6b\fP();
|
||||
.SH DESCRIPTION
|
||||
socket_sctp6b creates a blocking IPv6 SCTP/IP stream socket and returns a
|
||||
file descriptor pointing to that socket. If something goes wrong,
|
||||
socket_sctp6b returns -1, setting errno appropriately, without allocating
|
||||
any resources.
|
||||
|
||||
.SH EXAMPLE
|
||||
#include <socket.h>
|
||||
|
||||
int \fIs\fR;
|
||||
char \fIip\fR[16];
|
||||
uint16 \fIp\fR;
|
||||
|
||||
\fIs\fR = socket_sctp6b();
|
||||
socket_bind6(s,ip,p);
|
||||
socket_connect6(s,ip,p,0);
|
||||
|
||||
.SH "SEE ALSO"
|
||||
socket_sctp6(3), socket_bind4(3), socket_bind6(3)
|
@ -0,0 +1,56 @@
|
||||
#include <sys/types.h>
|
||||
#ifndef __MINGW32__
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include "windoze.h"
|
||||
#include <errno.h>
|
||||
#include "haveip6.h"
|
||||
#include "socket.h"
|
||||
#include "ndelay.h"
|
||||
|
||||
#ifndef EAFNOSUPPORT
|
||||
#define EAFNOSUPPORT EINVAL
|
||||
#endif
|
||||
#ifndef EPFNOSUPPORT
|
||||
#define EPFNOSUPPORT EAFNOSUPPORT
|
||||
#endif
|
||||
#ifndef EPROTONOSUPPORT
|
||||
#define EPROTONOSUPPORT EAFNOSUPPORT
|
||||
#endif
|
||||
|
||||
int socket_sctp6b(void)
|
||||
{
|
||||
#ifndef IPPROTO_SCTP
|
||||
errno=EPROTONOSUPPORT;
|
||||
return -1;
|
||||
#else
|
||||
#ifdef LIBC_HAS_IP6
|
||||
int s;
|
||||
|
||||
__winsock_init();
|
||||
if (noipv6) goto compat;
|
||||
s = winsock2errno(socket(PF_INET6,SOCK_STREAM,IPPROTO_SCTP));
|
||||
if (s == -1) {
|
||||
if (errno == EINVAL || errno == EAFNOSUPPORT || errno == EPFNOSUPPORT || errno == EPROTONOSUPPORT) {
|
||||
compat:
|
||||
s=winsock2errno(socket(AF_INET,SOCK_STREAM,IPPROTO_SCTP));
|
||||
noipv6=1;
|
||||
if (s==-1) return -1;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
#ifdef IPV6_V6ONLY
|
||||
{
|
||||
int zero=0;
|
||||
winsock2errno(setsockopt(s,IPPROTO_IPV6,IPV6_V6ONLY,(void*)&zero,sizeof(zero)));
|
||||
}
|
||||
#endif
|
||||
return s;
|
||||
#else
|
||||
return socket_sctp4b();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue