Rev. A
4-3
Programming Samples
UB-E02 Technical Reference Guide
4.2 Direct Printing by PORT9100
4.2.1 For Windows Console
The program is a sample of printing “EPSON UB-E02” to a TM printer with the UB-E02 from the
Windows shell, through the ethernet connection.
/* TCP9100 programming sample for win32
* HOW TO BUILD
* cl wtcp.cpp wsock32.lib
*/
#include <stdio.h>
#include <winsock.h>
int main(int argc, char* argv[])
{
WSADATA data;
SOCKET sock;
struct linger Linger;
struct sockaddr_in addr;
if (argc != 2) {
printf("usage: wtcp <IP address>\n");
exit(1);
}
/* Initialize windows socket */
WSAStartup(0x0101, &data);
/* Create socket */
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
fprintf(stderr, "Error socket(): %d\n", WSAGetLastError());
exit(1);
}
/* Set connection timeout */
Linger.l_onoff = 1;
Linger.l_linger = 60;
setsockopt(sock, SOL_SOCKET, SO_LINGER, (char*)&Linger, sizeof(struct linger));
/* 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) {
fprintf(stderr, "Error connect(): %d\n", WSAGetLastError());
exit(1);
}
printf("connected\n");
Содержание UB-E02
Страница 1: ...UB E02 Technical Reference Guide 10Base T 100Base TX Ethernet Interface board EPSON English 404999001 ...
Страница 2: ......
Страница 4: ...ii Rev A Revision Information Revision Page Altered Items and Contents Rev A ...
Страница 14: ...xii Contents Rev A ...
Страница 26: ...2 10 Installation Rev A ...
Страница 58: ...3 32 Utilities Rev A 3 3 2 11 Advanced Item Explanation Physical Layer Setting Set the communication method ...
Страница 85: ......
Страница 86: ...EPSON SEIKO EPSON CORPORATION Printed in Japan ...