RICOH SC-10 SERIES
Socket Mode Function Operating Instructions Ver.1.0.0
59/66
s1 = accept(s,
NULL
,
NULL
);
//Wait until communication from client and acquire client socket
if
(s1 < 0) {
printf(
"Wait error\n"
);
printf(
"Press any key\n"
);
scanf(
"%c"
, &ret);
return
-1;
}
// End acquisition of data received from client socket
result = recv(s1, buffer,
BUFSIZE
, 0);
if
(result < 0) {
printf(
"Receive error\n"
);
printf(
"Press any key\n"
);
scanf(
"%c"
, &ret);
return
-1;
}
// Display received string
for
(
int
i = 0;i <
MAX_MSGSIZE
;i++)
{
printf(
"%02X"
, buffer[i]);
}
printf(
"Received"
);
printf(
"Connection end\n"
);
SAFE_SOCK_CLOSE
(s1)
// End socket
#ifdef
WIN32
WSACleanup();
#endif
printf(
"Press any key\n"
);
scanf(
"%c"
, &ret);
return
0;
}
SOCK_TYPE
MakeServerSocket(
struct
sockaddr_in
*
dest
,
int
port
)
{
dest
->sin_port = htons(
port
);
//Specify port number
dest
->sin_family =
AF_INET
;
//IPv4
dest
->sin_addr.
s_addr
= htonl(
INADDR_ANY
);
return
socket(
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
);
}