Lines Matching defs:sockets

43   curl_socket_t *sockets;
44 int count; /* number of sockets actually stored in array */
45 int max_count; /* max number of sockets that fit in allocated array */
54 * Remove a file descriptor from a sockets array.
56 static void removeFd(struct Sockets *sockets, curl_socket_t fd, int mention)
63 for(i = 0; i < sockets->count; ++i) {
64 if(sockets->sockets[i] == fd) {
65 if(i < sockets->count - 1)
66 memmove(&sockets->sockets[i], &sockets->sockets[i + 1],
67 sizeof(curl_socket_t) * (sockets->count - (i + 1)));
68 --sockets->count;
74 * Add a file descriptor to a sockets array.
77 static int addFd(struct Sockets *sockets, curl_socket_t fd, const char *what)
84 removeFd(sockets, fd, 0);
88 if(!sockets->sockets) {
89 sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
90 if(!sockets->sockets)
92 sockets->max_count = 20;
94 else if(sockets->count + 1 > sockets->max_count) {
95 curl_socket_t *ptr = realloc(sockets->sockets, sizeof(curl_socket_t) *
96 (sockets->max_count + 20));
100 sockets->sockets = ptr;
101 sockets->max_count += 20;
106 sockets->sockets[sockets->count] = fd;
107 ++sockets->count;
120 struct ReadWriteSockets *sockets = userp;
132 if(addFd(&sockets->read, s, "read"))
136 if(addFd(&sockets->write, s, "write"))
140 removeFd(&sockets->read, s, 1);
141 removeFd(&sockets->write, s, 0);
216 * Update a fd_set with all of the sockets in use.
218 static void updateFdSet(struct Sockets *sockets, fd_set* fdset,
222 for(i = 0; i < sockets->count; ++i) {
223 FD_SET(sockets->sockets[i], fdset);
224 if(*maxFd < sockets->sockets[i] + 1) {
225 *maxFd = sockets->sockets[i] + 1;
246 struct Sockets *sockets, fd_set *fdset,
251 for(i = 0; i < sockets->count; ++i) {
252 if(FD_ISSET(sockets->sockets[i], fdset)) {
253 result = socket_action(curl, sockets->sockets[i], evBitmask, name);
265 struct ReadWriteSockets sockets = {{NULL, 0, 0}, {NULL, 0, 0}};
293 multi_setopt(m, CURLMOPT_SOCKETDATA, &sockets);
311 updateFdSet(&sockets.read, &readSet, &maxFd);
312 updateFdSet(&sockets.write, &writeSet, &maxFd);
327 /* Check the sockets for reading / writing */
328 res = checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read");
331 res = checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write");
360 free(sockets.read.sockets);
361 free(sockets.write.sockets);