Hello, I would like etablish a connection between a server on my VM and my card. Currently, I have a connection between my VM and my card (BL4S100) but only with my VM as client and my card as server. I have a server on my VM but my problem is to establish this connection considering my card as a client and not a server. I’m looking for somes example if you have or the beginning to move forward on my project. At the moment I have try this :
void main()
{
static tcp_Socket my_socket;
longword host;
tcp_Socket tsock;
struct sockaddr_in server_addr;
struct hostent *server;
char buffer[256];
ifconfig(IF_DEFAULT, IFS_IPADDR, aton("10.10.16.108"),
IFS_NETMASK, aton("255.255.255.0"),
IFS_ROUTER_SET, aton("10.10.16.253"),
IFS_UP,
IFS_END);
// création de la socket
sock_init();
while (ifpending(IF_DEFAULT) == IF_COMING_UP)
{
tcp_tick(NULL);
} //_or_exit(1);
// server = gethostbyname(argv[1]);
if (!(host = resolve(ADDRESS)))
{
puts("Could not resolve host");
exit(3);
}
port = atoi( PORT );
printf("Attempting to open '%s' on port %u
\r", ADDRESS,
port );
if ( !tcp_open( &tsock, 0, host, port , NULL ) > 0) {
puts("Unable to open TCP session");
exit(3);
}
printf("Waiting a maximum of %u seconds for connection to be established
\r", sock_delay );
while (!sock_established(&tsock) &&
sock_bytesready(&tsock)== -1){
tcp_tick(NULL);
}
puts("Socket is established");
sock_close( &tsock );
exit(0);
}
I don’t know/understand how to define the parameters to connect directly my card at my server.
Thank you for your help !