I am trying to establish a windows sockets connection using the Windows SDK functions.
First you need to initialise the dll with "WSAStartup"
then set up the socket using the "socket" command
and then connecting using the "connect" command
//establishes a connection to a specified socket.
SSvrStruct.sin_family = AF_INET;
SSvrStruct.sin_port = htons(502); // ASA standard port
SSvrStruct.sin_addr.s_addr = inet_addr(ip_adrs);
ConStatus = connect(socketHandle, &SSvrStruct, sizeof(sockaddr_in)); // connecting the socket
The connect command fails on my SSvrStruct pointer:
Type error in argument 2 to `connect'; found 'pointer to struct sockaddr_in' expected 'pointer to const struct sockaddr'.
so the easy solution is to typecast it:
But: ConStatus = connect(socketHandle, (sockaddr*)&SSvrStruct, sizeof(sockaddr_in)); // connecting the socket
yields another error: Undeclared identifier 'sockaddr'.
I am sure there is a simple solution to this, I just can not figure it out. Any ideas out there?
Attached the full source, just include WS2_32.lib in the project.
Thanks in advance
Jattie van der Linde
Engineering Manager, Software & Automation
TEL Magnetic Solutions Ltd