LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Examples of a server/client in labwindows CVI 4

Hi:

I am doing my graduation work, and i need to know how to do a connection beteween two computers in labwidows CVI 4.0. I red the examples that came with labwindows, but those examples are comfused. Can anybody help me with an example. A simple example, no to complicated, well wathever you can show me. Thanks.

VIVILO
0 Kudos
Message 1 of 4
(3,163 Views)
You can use tcp/ip library to do this. make 2 applications, one server,
other the client. In server app, call RegisterTCPServer function to listen
on a known port no. In the client application, use ConnectToTCPServer with
IP address of the machine running the server (server can run on same PC
which is running the client) and port no (where server is listening). Now
you can read/write from server or client using TcpRead/Write functions. It
is pretty simple.

server:-

int CVICALLBACK ServerTCPCB (unsigned handle, int event, int error, void
*callbackData);
RegisterTCPServer (portNum, ServerTCPCB, 0);
int CVICALLBACK ServerTCPCB (unsigned handle, int event, int error, void
*callbackData)
{
switch (event) {
case TCP_CONNECT:
printf("Client connected\n");
break;
case TCP_DATAREADY:
ServerTCPRead(handle, rxBuf, dataSize, 1000);
printf("Rx = %s\n", rxBuf);
break;
case TCP_DISCONNECT:
printf("Client disconnected\n");
break;
}
return 0;
}

Client:-

int CVICALLBACK ClientTCPCB (unsigned handle, int event, int error, void
*callbackData);
ConnectToTCPServer (&YourHandle, portNum, tempBuf, ClientTCPCB, NULL, 5000);
int CVICALLBACK ClientTCPCB (unsigned handle, int event, int error, void
*callbackData)
{
int dataSize = 256;
char rxBuf[256] = {0};

switch (event) {
case TCP_DATAREADY:
ClientTCPRead (handle, rxBuf, dataSize, 1000);
// print it
break;
case TCP_DISCONNECT:
printf("Server has closed connection!\n");
break;
}
return 0;
}

This mighth ave errors, I amjust illustrating what you need to do.


vishi

"vivilo" wrote in message
news:50650000000800000033730000-1042324653000@exchange.ni.com...
> Hi:
>
> I am doing my graduation work, and i need to know how to do a
> connection beteween two computers in labwidows CVI 4.0. I red the
> examples that came with labwindows, but those examples are comfused.
> Can anybody help me with an example. A simple example, no to
> complicated, well wathever you can show me. Thanks.
>
> VIVILO
0 Kudos
Message 2 of 4
(3,163 Views)
Thank you so much for your help. I am going to aplicate the instuctions that you said to me, and later i will give you an answered about the process. But really, thank you so much.

VIVILO
0 Kudos
Message 3 of 4
(3,163 Views)
Thank you Vishi Anand, I did what you say to me, anad I finished that program. Thank you so much.
0 Kudos
Message 4 of 4
(3,163 Views)