RICOH SC-10 SERIES
Socket Mode Function Operating Instructions Ver.1.0.0
61/66
The time and message are added to TCPDebugLog of the SC-10A when sending completes.
static
byte
[] resize(
byte
[]bytes,
byte
[] buf,
int
size)
{
if
(buf.Length != size)
Array
.Resize(
ref
buf, size);
return
bytes.Concat(buf).ToArray();
}
class
SC10TCPcliant
{
private
IPEndPoint
ServerIPEndPoint {
get
;
set
; }
private
Socket
{
get
;
set
; }
public
SC10TCPcliant(
IPAddress
ip,
int
port)
{
this
.ServerIPEndPoint =
new
IPEndPoint
(ip, port);
}
// Socket mode connection
public
void
Connect()
{
this
.Socket =
new
Socket
(
AddressFamily
.InterNetwork,
SocketType
.Stream,
ProtocolType
.Tcp);
try
{
this
.Socket.Connect(
this
.ServerIPEndPoint);
}
catch
(
Exception
e)
{
Console
.WriteLine(
"Connection failed.\ n"
+ e);
}
}
// Send message (synchronization process)
public
void
Send(
byte
[] sendBytes)
{
if
(sendBytes ==
null
)
return
;
if
(Socket.LocalEndPoint !=
null
)
this
.Socket.Send(sendBytes);
else
Console
.WriteLine(
"Sending failed."
) ;
}
}
}