RICOH SC-10 SERIES
Socket Mode Function Operating Instructions Ver.1.0.0
55/66
Sample Code
C Language
Send program
Start the sample code by calling the exe with a command.
Arguments can be specified. Specify the arguments in the order of "Message ID (hexadecimal notation)," "Device ID,"
"Device name," "IP address," and "Port number."
sample.exe -messageID -deviceID -devicename -IPaddr(xxx.xxx.xxx.xx) -portnum
If arguments are not specified, "00000001," "73b95610," "SC10a," "192.168.183.51," and "56109" are entered.
#define
_CRT_SECURE_NO_WARNINGS
#include
<stdio.h>
#include
<winsock2.h>
//if linux comment out this
#ifdef
WIN32
#pragma
comment
(
lib
,
"ws2_32.lib"
)
#include
<ws2tcpip.h>
#endif
#ifdef
WIN32
#define
HERROR
WSAGetLastError()
#define
SAFE_SOCK_CLOSE
(sock)
if
((sock) !=
INVALID_SOCKET
){ closesocket((sock)); (sock)=
INVALID_SOCKET
; }
#define
SOCK_TYPE
SOCKET
#define
SET_SOCKADDR_IPV4
(addr, value)
InetPton
((addr)->sin_family, (
PCSTR
)(value), &(addr)-
>sin_addr.S_un.S_addr);
//(addr).sin_addr.S_un.S_addr = (value)
#endif
#define
MAX_MSGSIZE
1024
#define
BUFSIZE
(
MAX_MSGSIZE
+1)
SOCK_TYPE
MakeSocket(
struct
sockaddr_in
*
dest
,
char
*
destination
,
int
port
);
void
createData(
struct
dataformat
*
data
,
char
*
buff
);
void
setdata(
struct
dataformat
*
data
,
int
argc
,
char
*
argv
[]);
int
checkdef(
int
argc
,
char
*
str
[]);
void
num2buff(
u_int
num
,
int
size
,
int
start
,
char
*
buff
);
struct
dataformat
{
u_int
messageID;
u_int
DeviceID;
char
DeviceName[64];
};