Lines Matching defs:sock
38 #define read(sock,buf,len) recv(sock,buf,len,0)
39 #define write(sock,buf,len) send(sock,buf,len,0)
142 i = read(client->sock, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered);
180 i = read(client->sock, out, n);
246 j = write(client->sock, buf + i, (n - i));
258 FD_SET(client->sock,&fds);
260 if (select(client->sock+1, NULL, &fds, NULL, NULL) <= 0) {
304 int sock;
315 sock = socket(AF_INET, SOCK_STREAM, 0);
316 if (sock < 0) {
324 if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
326 close(sock);
330 if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
333 close(sock);
337 return sock;
344 int sock;
364 sock = -1;
367 sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
368 if (sock >= 0)
370 if (connect(sock, res->ai_addr, res->ai_addrlen) == 0)
372 close(sock);
373 sock = -1;
379 if (sock == -1)
385 if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
388 close(sock);
392 return sock;
409 int sock;
414 sock = socket(AF_UNIX, SOCK_STREAM, 0);
415 if (sock < 0) {
420 if (connect(sock, (struct sockaddr *)&addr, sizeof(addr.sun_family) + strlen(addr.sun_path)) < 0) {
422 close(sock);
426 return sock;
440 int sock, port;
449 sock = socket(AF_INET, SOCK_STREAM, 0);
450 if (sock < 0) {
457 if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) {
458 close(sock);
463 close(sock);
488 int sock;
504 sock = socket(AF_INET, SOCK_STREAM, 0);
505 if (sock < 0) {
510 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
513 close(sock);
517 if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
519 close(sock);
545 if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) {
551 if (p->ai_family == AF_INET6 && setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&one, sizeof(one)) < 0) {
553 close(sock);
559 if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof(one)) < 0) {
561 close(sock);
566 if (bind(sock, p->ai_addr, p->ai_addrlen) < 0) {
567 close(sock);
583 if (listen(sock, 5) < 0) {
585 close(sock);
589 return sock;
600 int sock;
605 sock = accept(listenSock, (struct sockaddr *) &addr, &addrlen);
606 if (sock < 0) {
611 if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
614 close(sock);
618 return sock;
627 SetNonBlocking(int sock)
631 if(ioctlsocket(sock, FIONBIO, &block) == SOCKET_ERROR) {
634 int flags = fcntl(sock, F_GETFL);
635 if(flags < 0 || fcntl(sock, F_SETFL, flags | O_NONBLOCK) < 0) {
650 SetDSCP(int sock, int dscp)
660 if(getsockname(sock, &addr, &addrlen) != 0) {
682 if(setsockopt(sock, level, cmd, (void*)&dscp, sizeof(dscp)) != 0) {
731 SameMachine(int sock)
736 getpeername(sock, (struct sockaddr *)&peeraddr, &addrlen);
737 getsockname(sock, (struct sockaddr *)&myaddr, &addrlen);
800 FD_SET(client->sock,&fds);
802 num=select(client->sock+1, &fds, NULL, NULL, &timeout);