2009-06-25 13 views
6

Usiłuję wyłączyć algorytm nagle'a dla gniazda BSD używając:Jak ustawić TCP_NODELAY na gnieździe BSD w systemie Solaris?

setsockopt(newSock, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, sizeof flag); 

ale kompilator twierdzi TCP_NODELAY nie został dotąd:

error: `TCP_NODELAY' undeclared (first use this function) 

Jest to pełna lista obejmuje na plik ten znajduje się w:

#include <arpa/inet.h> 
#include <fcntl.h> 
#include <iostream> 
#include <netdb.h> 
#include <string> 
#include <sys/socket.h> 
#include <sys/types.h> 
using namespace std; 

mam też opcje linkera -lnsl i -lsocket, ale t po prostu się nie skompiluje. Czy czegoś brakuje?

Wszystko to jest na maszynie Solaris 8.

Odpowiedz

12

Wygląda na to, że brakuje Ci #include <netinet/tcp.h> - to tutaj TCP_... definiuje transmisję na żywo.

+0

Dokładnie, dzięki! –

+0

Próbowałem tego w systemie Solaris 10 (musiałem dodać go po nagłówkach, które już zawierałeś) i działało. Mam błędy z włączeniem - ale próbowałem program C, więc musiałem go zmienić na poundifdef

2

Nie mam pod ręką pudła Solaris, tylko Linux.

grep -ri TCP_NODELAY /usr/include/* 

skutkuje:

/usr/include/linux/tcp.h:#define TCP_NODELAY   1  /* Turn off Nagle's algorithm. */ 
/usr/include/netinet/tcp.h:#define  TCP_NODELAY  1  /* Don't delay send to coalesce packets */ 

Może spróbujesz czegoś podobnego?

Powiązane problemy