Subversion Repositories HelenOS

Rev

Rev 4755 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4755 Rev 4756
Line 50... Line 50...
50
/** @name Socket application programming interface
50
/** @name Socket application programming interface
51
 */
51
 */
52
/*@{*/
52
/*@{*/
53
 
53
 
54
/** Creates a new socket.
54
/** Creates a new socket.
55
 *  @param domain The socket protocol family. Input parameter.
55
 *  @param[in] domain The socket protocol family.
56
 *  @param type Socket type. Input parameter.
56
 *  @param[in] type Socket type.
57
 *  @param protocol Socket protocol. Input parameter.
57
 *  @param[in] protocol Socket protocol.
58
 *  @returns The socket identifier on success.
58
 *  @returns The socket identifier on success.
59
 *  @returns EPFNOTSUPPORT if the protocol family is not supported.
59
 *  @returns EPFNOTSUPPORT if the protocol family is not supported.
60
 *  @returns ESOCKNOTSUPPORT if the socket type is not supported.
60
 *  @returns ESOCKNOTSUPPORT if the socket type is not supported.
61
 *  @returns EPROTONOSUPPORT if the protocol is not supported.
61
 *  @returns EPROTONOSUPPORT if the protocol is not supported.
62
 *  @returns ENOMEM if there is not enough memory left.
62
 *  @returns ENOMEM if there is not enough memory left.
63
 *  @returns Other error codes as defined for the NET_SOCKET message.
63
 *  @returns Other error codes as defined for the NET_SOCKET message.
64
 */
64
 */
65
int socket( int domain, int type, int protocol );
65
int socket( int domain, int type, int protocol );
66
 
66
 
67
/** Binds the socket to a port address.
67
/** Binds the socket to a port address.
68
 *  @param socket_id Socket identifier. Input parameter.
68
 *  @param[in] socket_id Socket identifier.
69
 *  @param my_addr The port address. Input parameter.
69
 *  @param[in] my_addr The port address.
70
 *  @param addrlen The address length. Input parameter.
70
 *  @param[in] addrlen The address length.
71
 *  @returns EOK on success.
71
 *  @returns EOK on success.
72
 *  @returns ENOTSOCK if the socket is not found.
72
 *  @returns ENOTSOCK if the socket is not found.
73
 *  @returns EBADMEM if the my_addr parameter is NULL.
73
 *  @returns EBADMEM if the my_addr parameter is NULL.
74
 *  @returns NO_DATA if the addlen parameter is zero (0).
74
 *  @returns NO_DATA if the addlen parameter is zero (0).
75
 *  @returns Other error codes as defined for the NET_SOCKET_BIND message.
75
 *  @returns Other error codes as defined for the NET_SOCKET_BIND message.
76
 */
76
 */
77
int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen );
77
int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen );
78
 
78
 
79
/** Sets the number of connections waiting to be accepted.
79
/** Sets the number of connections waiting to be accepted.
80
 *  @param socket_id Socket identifier. Input parameter.
80
 *  @param[in] socket_id Socket identifier.
81
 *  @param backlog The maximum number of waiting sockets to be accepted. Input parameter.
81
 *  @param[in] backlog The maximum number of waiting sockets to be accepted.
82
 *  @returns EOK on success.
82
 *  @returns EOK on success.
83
 *  @returns EINVAL if the backlog parameter is not positive (<=0).
83
 *  @returns EINVAL if the backlog parameter is not positive (<=0).
84
 *  @returns ENOTSOCK if the socket is not found.
84
 *  @returns ENOTSOCK if the socket is not found.
85
 *  @returns Other error codes as defined for the NET_SOCKET_LISTEN message.
85
 *  @returns Other error codes as defined for the NET_SOCKET_LISTEN message.
86
 */
86
 */
87
int listen( int socket_id, int backlog );
87
int listen( int socket_id, int backlog );
88
 
88
 
89
/** Accepts waiting socket.
89
/** Accepts waiting socket.
90
 *  Blocks until such a socket exists.
90
 *  Blocks until such a socket exists.
91
 *  @param socket_id Socket identifier. Input parameter.
91
 *  @param[in] socket_id Socket identifier.
92
 *  @param cliaddr The remote client address. Output parameter.
92
 *  @param[out] cliaddr The remote client address.
93
 *  @param addrlen The address length. Input parameter.
93
 *  @param[in] addrlen The address length.
94
 *  @returns EOK on success.
94
 *  @returns EOK on success.
95
 *  @returns EBADMEM if the cliaddr or addrlen parameter is NULL.
95
 *  @returns EBADMEM if the cliaddr or addrlen parameter is NULL.
96
 *  @returns EINVAL if the backlog parameter is not positive (<=0).
96
 *  @returns EINVAL if the backlog parameter is not positive (<=0).
97
 *  @returns ENOTSOCK if the socket is not found.
97
 *  @returns ENOTSOCK if the socket is not found.
98
 *  @returns Other error codes as defined for the NET_SOCKET_ACCEPT message.
98
 *  @returns Other error codes as defined for the NET_SOCKET_ACCEPT message.
99
 */
99
 */
100
int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen );
100
int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen );
101
 
101
 
102
/** Connects socket to the remote server.
102
/** Connects socket to the remote server.
103
 *  @param socket_id Socket identifier. Input parameter.
103
 *  @param[in] socket_id Socket identifier.
104
 *  @param serv_addr The remote server address. Input parameter.
104
 *  @param[in] serv_addr The remote server address.
105
 *  @param addrlen The address length. Input parameter.
105
 *  @param[in] addrlen The address length.
106
 *  @returns EOK on success.
106
 *  @returns EOK on success.
107
 *  @returns EBADMEM if the serv_addr parameter is NULL.
107
 *  @returns EBADMEM if the serv_addr parameter is NULL.
108
 *  @returns NO_DATA if the addlen parameter is zero (0).
108
 *  @returns NO_DATA if the addlen parameter is zero (0).
109
 *  @returns ENOTSOCK if the socket is not found.
109
 *  @returns ENOTSOCK if the socket is not found.
110
 *  @returns Other error codes as defined for the NET_SOCKET_CONNECT message.
110
 *  @returns Other error codes as defined for the NET_SOCKET_CONNECT message.
111
 */
111
 */
112
int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen );
112
int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen );
113
 
113
 
114
/** Closes the socket.
114
/** Closes the socket.
115
 *  @param socket_id Socket identifier. Input parameter.
115
 *  @param[in] socket_id Socket identifier.
116
 *  @returns EOK on success.
116
 *  @returns EOK on success.
117
 *  @returns ENOTSOCK if the socket is not found.
117
 *  @returns ENOTSOCK if the socket is not found.
118
 *  @returns EINPROGRESS if there is another blocking function in progress.
118
 *  @returns EINPROGRESS if there is another blocking function in progress.
119
 *  @returns Other error codes as defined for the NET_SOCKET_CLOSE message.
119
 *  @returns Other error codes as defined for the NET_SOCKET_CLOSE message.
120
 */
120
 */
121
int closesocket( int socket_id );
121
int closesocket( int socket_id );
122
 
122
 
123
/** Sends data via the socket.
123
/** Sends data via the socket.
124
 *  @param socket_id Socket identifier. Input parameter.
124
 *  @param[in] socket_id Socket identifier.
125
 *  @param data The data to be sent. Input parameter.
125
 *  @param[in] data The data to be sent.
126
 *  @param datalength The data length. Input parameter.
126
 *  @param[in] datalength The data length.
127
 *  @param flags Various send flags. Input parameter.
127
 *  @param[in] flags Various send flags.
128
 *  @returns EOK on success.
128
 *  @returns EOK on success.
129
 *  @returns ENOTSOCK if the socket is not found.
129
 *  @returns ENOTSOCK if the socket is not found.
130
 *  @returns EBADMEM if the data parameter is NULL.
130
 *  @returns EBADMEM if the data parameter is NULL.
131
 *  @returns NO_DATA if the datalength parameter is zero (0).
131
 *  @returns NO_DATA if the datalength parameter is zero (0).
132
 *  @returns Other error codes as defined for the NET_SOCKET_SEND message.
132
 *  @returns Other error codes as defined for the NET_SOCKET_SEND message.
133
 */
133
 */
134
int send( int socket_id, void * data, size_t datalength, int flags );
134
int send( int socket_id, void * data, size_t datalength, int flags );
135
 
135
 
136
/** Sends data via the socket to the remote address.
136
/** Sends data via the socket to the remote address.
137
 *  Binds the socket to a free port if not already connected/bound.
137
 *  Binds the socket to a free port if not already connected/bound.
138
 *  @param socket_id Socket identifier. Input parameter.
138
 *  @param[in] socket_id Socket identifier.
139
 *  @param data The data to be sent. Input parameter.
139
 *  @param[in] data The data to be sent.
140
 *  @param datalength The data length. Input parameter.
140
 *  @param[in] datalength The data length.
141
 *  @param flags Various send flags. Input parameter.
141
 *  @param[in] flags Various send flags.
142
 *  @param toaddr The destination address. Input parameter.
142
 *  @param[in] toaddr The destination address.
143
 *  @param addrlen The address length. Input parameter.
143
 *  @param[in] addrlen The address length.
144
 *  @returns EOK on success.
144
 *  @returns EOK on success.
145
 *  @returns ENOTSOCK if the socket is not found.
145
 *  @returns ENOTSOCK if the socket is not found.
146
 *  @returns EBADMEM if the data or toaddr parameter is NULL.
146
 *  @returns EBADMEM if the data or toaddr parameter is NULL.
147
 *  @returns NO_DATA if the datalength or the addrlen parameter is zero (0).
147
 *  @returns NO_DATA if the datalength or the addrlen parameter is zero (0).
148
 *  @returns Other error codes as defined for the NET_SOCKET_SENDTO message.
148
 *  @returns Other error codes as defined for the NET_SOCKET_SENDTO message.
149
 */
149
 */
150
int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen );
150
int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen );
151
 
151
 
152
/** Receives data via the socket.
152
/** Receives data via the socket.
153
 *  @param socket_id Socket identifier. Input parameter.
153
 *  @param[in] socket_id Socket identifier.
154
 *  @param data The data buffer to be filled. Output parameter.
154
 *  @param[out] data The data buffer to be filled.
155
 *  @param datalength The data length. Input parameter.
155
 *  @param[in] datalength The data length.
156
 *  @param flags Various receive flags. Input parameter.
156
 *  @param[in] flags Various receive flags.
157
 *  @returns EOK on success.
157
 *  @returns EOK on success.
158
 *  @returns ENOTSOCK if the socket is not found.
158
 *  @returns ENOTSOCK if the socket is not found.
159
 *  @returns EBADMEM if the data parameter is NULL.
159
 *  @returns EBADMEM if the data parameter is NULL.
160
 *  @returns NO_DATA if the datalength parameter is zero (0).
160
 *  @returns NO_DATA if the datalength parameter is zero (0).
161
 *  @returns Other error codes as defined for the NET_SOCKET_RECV message.
161
 *  @returns Other error codes as defined for the NET_SOCKET_RECV message.
162
 */
162
 */
163
int recv( int socket_id, void * data, size_t datalength, int flags );
163
int recv( int socket_id, void * data, size_t datalength, int flags );
164
 
164
 
165
/** Receives data via the socket.
165
/** Receives data via the socket.
166
 *  @param socket_id Socket identifier. Input parameter.
166
 *  @param[in] socket_id Socket identifier.
167
 *  @param data The data buffer to be filled. Output parameter.
167
 *  @param[out] data The data buffer to be filled.
168
 *  @param datalength The data length. Input parameter.
168
 *  @param[in] datalength The data length.
169
 *  @param flags Various receive flags. Input parameter.
169
 *  @param[in] flags Various receive flags.
170
 *  @param fromaddr The source address. Output parameter.
170
 *  @param[out] fromaddr The source address.
171
 *  @param addrlen The address length. The maximum address length is read. The actual address length is set. Input/output parameter.
171
 *  @param[in,out] addrlen The address length. The maximum address length is read. The actual address length is set.
172
 *  @returns EOK on success.
172
 *  @returns EOK on success.
173
 *  @returns ENOTSOCK if the socket is not found.
173
 *  @returns ENOTSOCK if the socket is not found.
174
 *  @returns EBADMEM if the data or fromaddr parameter is NULL.
174
 *  @returns EBADMEM if the data or fromaddr parameter is NULL.
175
 *  @returns NO_DATA if the datalength or addrlen parameter is zero (0).
175
 *  @returns NO_DATA if the datalength or addrlen parameter is zero (0).
176
 *  @returns Other error codes as defined for the NET_SOCKET_RECVFROM message.
176
 *  @returns Other error codes as defined for the NET_SOCKET_RECVFROM message.
177
 */
177
 */
178
int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen );
178
int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen );
179
 
179
 
180
/** Gets socket option.
180
/** Gets socket option.
181
 *  @param socket_id Socket identifier. Input parameter.
181
 *  @param[in] socket_id Socket identifier.
182
 *  @param level The socket options level. Input parameter.
182
 *  @param[in] level The socket options level.
183
 *  @param optname The socket option to be get. Input parameter.
183
 *  @param[in] optname The socket option to be get.
184
 *  @param value The value buffer to be filled. Output parameter.
184
 *  @param[out] value The value buffer to be filled.
185
 *  @param optlen The value buffer length. The maximum length is read. The actual length is set. Input/output parameter.
185
 *  @param[in,out] optlen The value buffer length. The maximum length is read. The actual length is set.
186
 *  @returns EOK on success.
186
 *  @returns EOK on success.
187
 *  @returns ENOTSOCK if the socket is not found.
187
 *  @returns ENOTSOCK if the socket is not found.
188
 *  @returns EBADMEM if the value or optlen parameter is NULL.
188
 *  @returns EBADMEM if the value or optlen parameter is NULL.
189
 *  @returns NO_DATA if the optlen parameter is zero (0).
189
 *  @returns NO_DATA if the optlen parameter is zero (0).
190
 *  @returns Other error codes as defined for the NET_SOCKET_GETSOCKOPT message.
190
 *  @returns Other error codes as defined for the NET_SOCKET_GETSOCKOPT message.
191
 */
191
 */
192
int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen );
192
int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen );
193
 
193
 
194
/** Sets socket option.
194
/** Sets socket option.
195
 *  @param socket_id Socket identifier. Input parameter.
195
 *  @param[in] socket_id Socket identifier.
196
 *  @param level The socket options level. Input parameter.
196
 *  @param[in] level The socket options level.
197
 *  @param optname The socket option to be set. Input parameter.
197
 *  @param[in] optname The socket option to be set.
198
 *  @param value The value to be set. Input parameter.
198
 *  @param[in] value The value to be set.
199
 *  @param optlen The value length. Input parameter.
199
 *  @param[in] optlen The value length.
200
 *  @returns EOK on success.
200
 *  @returns EOK on success.
201
 *  @returns ENOTSOCK if the socket is not found.
201
 *  @returns ENOTSOCK if the socket is not found.
202
 *  @returns EBADMEM if the value parameter is NULL.
202
 *  @returns EBADMEM if the value parameter is NULL.
203
 *  @returns NO_DATA if the optlen parameter is zero (0).
203
 *  @returns NO_DATA if the optlen parameter is zero (0).
204
 *  @returns Other error codes as defined for the NET_SOCKET_SETSOCKOPT message.
204
 *  @returns Other error codes as defined for the NET_SOCKET_SETSOCKOPT message.