DOC-USR-0272-01
FSDI-1XA User’s Guide
79
printf("\nInitialising Winsock...");
if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0)
{
printf("Failed. Error Code : %d", WSAGetLastError());
return -1;
}
//open tcp socket
s = socket(AF_INET, SOCK_STREAM, 0);
if (s == INVALID_SOCKET)
{
printf("error opening socket : %d\n", WSAGetLastError());
return -2;
}
printf("connecting to %s:%s\n", argv[1], argv[2]);
if (argv[2] != NULL)
{
portno = strtoul(argv[2], NULL, 10);
}
memset((char *) &serv_addr, 0,sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
serv_addr.sin_port = htons(portno);
if (connect(s,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
{
printf("ERROR connecting\n");
return -3;
}
printf("connected!\n");
}
if (s != INVALID_SOCKET) {
help();
while ( 1) {
ch = _getch();
if (ch == 'i' || ch == 'I')
{
printf("Zoom In\n");
visca_send(s, cmdVisca[0]);
visca_receive(s,buf,sizeof(buf), 1);
}
if (ch == 'o' || ch == 'O')
{
printf("Zoom Out\n");
visca_send(s, cmdVisca[1]);
visca_receive(s,buf,sizeof(buf), 1);
}
if (ch == 67) //Right
{
//printf("Right\n");
}
if (ch == 68) //Left
{
//printf("Left\n");
}
if (ch == 86 || ch == 118 )
{
printf("Version Inq\n");
visca_send(s, cmdVisca[3]);
visca_receive(s,buf,sizeof(buf), 1);
}
if (ch == 'f' || ch == 'F')
{
printf("Flip On\n");
visca_send(s, cmdVisca[4]);
visca_receive(s,buf,sizeof(buf), 1);
}
if (ch == 'n' || ch == 'N')
{