Chapter 3 Programming Samples
49
3
For Linux
The
program
is
a
sample
of
printing
“EPSON
UB
‐
E03”
to
a
TM
printer
with
the
UB
‐
E03
from
the
Linux
shell,
through
the
Ethernet
connection.
/* TCP9100 programming sample for LINUX
* HOW TO BUILD
* cc ltcp.c
*/
#include <stdio.h>
#include <netdb.h>
int main(int argc, char* argv[])
{
int sock;
struct sockaddr_in addr;
if (argc != 2) {
printf("usage: ltcp <ip address>\n");
exit(1);
}
/* create socket */
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0){
perror("socket()");
exit(1);
}
/* initialize the parameter */
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(9100);
addr.sin_addr.s_addr = inet_addr(argv[1]);
/* connect */
if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0){
perror("connect()");
}
printf("connected\n");
/* send data */
send(sock, "EPSON\n", 6, 0);
/* close socket */
close(sock);
return 0;
}
Содержание UB-E03
Страница 19: ...Chapter 2 Set up 19 2 Windows Vista 1 Click View status in the Control Panel 2 Click the Properties button ...
Страница 21: ...Chapter 2 Set up 21 2 2 Click Network Connections 3 Double click Local Area Connection ...
Страница 30: ...30 5 Click the Configuration button 6 Change the setting if necessary and click the OK button ...
Страница 46: ...46 ...
Страница 58: ...58 ...