6 #include <sys/socket.h> 7 #include <netinet/in.h> 12 typedef int socklen_t;
26 printf(
"zeroing...\n");
28 printf(
"zeroing done..\n");
31 sock = socket (AF_INET, SOCK_STREAM, 0);
32 printf(
"create socket..\n");
36 printf(
"no socket...\n");
41 myaddr.sin_family = AF_INET;
42 myaddr.sin_port = htons (localport);
52 printf(
"setting socket opts reuse...\n");
53 if(setsockopt(
sock,SOL_SOCKET,SO_REUSEADDR,(
char *)&blen,
sizeof(blen))<0)
58 printf(
"binding...\n");
64 { perror (
"bind failed");
91 printf(
"deleting DTCtcp\n");
93 shutdown(
sock,SHUT_RDWR);
101 maddr = htonl (maddr);
108 unsigned long maddr =
clientAddr.sin_addr.s_addr;
109 maddr = htonl (maddr);
117 return shutdown(
sock,SHUT_RDWR);
128 if (listen (
sock, 2) < 0)
130 perror (
"listen failed");
139 perror (
"accept failed");
143 return new DTCtcp(snew,0);
155 perror (
"connect failed");
165 clientAddr.sin_addr.s_addr = inet_addr (host);
170 perror (
"connect failed");
189 int retva =
select (1,&rfds,0,&rfds,&tv);
191 if (FD_ISSET(0,&rfds))
return 1;
206 int readnow = recv (
sock, &buffer[howmany], toberead,0) ;
209 {printf(
"some rrorrs...%d\n",errno);
throw DTtcpExcp(errno);}
211 howmany+=readnow; toberead-=readnow;}
212 }
while (toberead>0);
int Receive(char *buffer, int size)
int Send(char *buffer, int size)
struct sockaddr_in myaddr
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
void Connect(const char *hostaddr, int port)
edm::Handle< T > connect(const T *&ptr, edm::EDGetTokenT< T > token, const edm::Event &evt)
struct sockaddr_in clientAddr
int WaitData(int timeout)