39#ifdef G4VIS_BUILD_VRML_DRIVER
46#include <sys/socket.h>
47#include <netinet/in.h>
73 fd = socket(AF_INET, SOCK_STREAM, 0);
75 fputs(
"error: socket.\n", stderr);
81int FRClient::connect(
const char *hostname,
int port_)
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);
119int FRClient::send(
const char *sendbuf)
121 int len = strlen(sendbuf);
123 if (::send(fd, sendbuf, len, 0) < 0) {
124 fputs(
"error: Send()\n", stderr);
130int 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);
G4GLOB_DLL std::ostream G4cout
static Verbosity GetVerbosity()