summaryrefslogtreecommitdiff
path: root/man/socket_tcp.3
blob: 3616ed77b2e911b9b7ebd1e04c53b85d69482354 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.TH qlibs: socket_tcp 3
.SH NAME
socket_tcp \- setting up TCP sockets
.SH SYNTAX
.B #include \(dqsocket_if.h\(dq

int \fBsocket_tcp4\fP();
.br
int \fBsocket_tcp6\fP();
.br
int \fBsocket_tcp\fP();
.SH DESCRIPTION
.B socket_tcp4 
creates a non-blocking TCP/IPv4 stream socket and 
providing a file descriptor pointing to that socket.  

.B socket_tcp6 
creates a non-blocking TCP/IPv6 stream socket and 
providing a file descriptor pointing to that socket.

.B socket_tcp
creates a non-blocking IPv6 TCP/IP socket calling
.B socket_tcp6 
unless it can't bind to IPv6 and now facilitating
.BR socket_tcp4 .
.SH "REMOTE CODES"
All these routines return
.IR 0
except in case of failures, returning
.I -1 
and setting 
.I errno 
appropriately, without allocating any resources.
.SH EXAMPLE
  #include <socket_if.h>

  int \fIt\fR;
  char \fIlocalip\fR[16];
  char \fIremoteip\fR[16];
  uint16 \fIp\fR;

  if (ip6_isv4mapped(remoteip)) {
    t = socket_tcp4();
    socket_bind4(t,localip + 12,0);
  } else {
    t = socket_tcp6();
    socket_bind6(t,localip,0,0);
  }
  socket_connect(s,remoteip,p,0);
.SH "SEE ALSO"
socket_if(3), 
socket_bind(3), 
socket_connect(3), 
socket_info(3), 
socket_recv(3), 
socket_send(3), 
socket_setup(3), 
socket_udp(3)