39 #ifdef G4VIS_BUILD_VRML_DRIVER
45 #include <sys/types.h>
46 #include <sys/socket.h>
47 #include <netinet/in.h>
48 #include <arpa/inet.h>
70 int FRClient::create()
73 fd =
socket(AF_INET, SOCK_STREAM, 0);
75 fputs(
"error: socket.\n", stderr);
84 struct sockaddr_in sa;
89 memset( (
char *)&sa,
'\0',
sizeof(sa)) ;
90 sa.sin_family = AF_INET;
91 sa.sin_port = htons(port);
94 if (hostname == NULL) {
95 hostname =
"localhost";
98 hp = gethostbyname(hostname) ;
105 memcpy( (
char * )&sa.sin_addr, (
char * )hp->h_addr, hp->h_length );
108 if (::
connect(
fd, (
struct sockaddr *)&sa,
sizeof(sa)) == -1) {
109 fputs(
"error: connect\n", stderr);
119 int FRClient::send(
const char *sendbuf)
121 int len = strlen(sendbuf);
123 if (::send(
fd, sendbuf, len, 0) < 0) {
124 fputs(
"error: Send()\n", stderr);
130 int FRClient::receive(
char *recvbuf)
134 memset(recvbuf,
'\0', FRSendLength + 1);
135 len = ::recv(
fd, recvbuf, FRSendLength, 0);
137 fputs(
"error: Receive()\n", stderr);
148 if (::shutdown(
fd, 2) < 0) {
149 fputs(
"error: shutdown\n", stderr);
156 #endif //G4VIS_BUILD_VRML_DRIVER