40 #ifdef G4VIS_BUILD_VRML_DRIVER
46 #include <sys/types.h>
47 #include <sys/socket.h>
48 #include <netinet/in.h>
49 #include <arpa/inet.h>
71 int FRClient::create()
74 fd = socket(AF_INET, SOCK_STREAM, 0);
76 fputs(
"error: socket.\n", stderr);
82 int FRClient::connect(
const char *hostname,
int port_)
85 struct sockaddr_in sa;
90 memset( (
char *)&sa,
'\0',
sizeof(sa)) ;
91 sa.sin_family = AF_INET;
92 sa.sin_port = htons(port);
95 if (hostname == NULL) {
96 hostname =
"localhost";
99 hp = gethostbyname(hostname) ;
106 memcpy( (
char * )&sa.sin_addr, (
char * )hp->h_addr, hp->h_length );
109 if (::connect(fd, (
struct sockaddr *)&sa,
sizeof(sa)) == -1) {
110 fputs(
"error: connect\n", stderr);
120 int FRClient::send(
const char *sendbuf)
122 int len = strlen(sendbuf);
124 if (::send(fd, sendbuf, len, 0) < 0) {
125 fputs(
"error: Send()\n", stderr);
131 int FRClient::receive(
char *recvbuf)
135 memset(recvbuf,
'\0', FRSendLength + 1);
136 len = ::recv(fd, recvbuf, FRSendLength, 0);
138 fputs(
"error: Receive()\n", stderr);
149 if (::shutdown(fd, 2) < 0) {
150 fputs(
"error: shutdown\n", stderr);
157 #endif //G4VIS_BUILD_VRML_DRIVER
G4GLOB_DLL std::ostream G4cout
static Verbosity GetVerbosity()