User Tools

Site Tools

한국어

moacon:connect:index

connect

u8 connect (u8 socketNum, u8* destIP, u16 destPort)

socketNum : The socket number (0~3
destIP : The IP address of the device to connect to
destPort : The TCP port to connect to
Returns 1 if successful, 0 otherwise

Requests a connection to IP address, destIP, on port, destPort, using the socket, socketNum. The socket, socketNum, must first be opened using the socketOpen function.

u8 GatewayIP[]={192,168,0,1};
u8 SubnetMask[]={255,255,255,0};
u8 MacAdr[]={0,0,34,53,12,0};
u8 DeviceIp[]={192,168,0,12};
u8 destIP[]={192,168,0,2};
netBegin(GatewayIP, SubnetMask, MacAdr, DeviceIp);
socketOpen(0,82);
connect(0,destIP,5000);

NOTE: Any socket connect with a call to connect must eventually be disconnected with a call to disConnect. The Ethernet module is not reset when the CPU module is reset, so, it may be necessary to call disConnect at the beginning of a program to be sure the socket is disconnected before it is used.

Network sample program

go MOACON home

moacon/connect/index.txt · Last modified: 2016/04/14 11:07 (external edit)