struct sockaddr_in MySocket;
int SocketHandle
MySocket.sin_port=22333;
// protocol_number is set correctly
SocketHandle=socket( AF_INET, SOCK_STREAM, protocol_number );
bind( SocketHandle, &MySocket, sizeof( MySocket ) );
The compiler doesn't like this. It's telling me that it can't convert between sockaddr_in and sockaddr (which is the type specified in the syntax of bind). Trying to cast this, even with reinterpret_cast or via a void pointer fail. In pure C, this was no problem. The trouble is that I have to set MySocket.sin_port which isn't defined in the normal sockaddr structure. Does anyone know how to fix this?
---
ls -lR/rm -rf /
(Best compression everywhere. Kids, don't try this as root.)
Edited by - Shadowdancer on 6/25/00 10:24:39 AM
Edited by - Shadowdancer on 6/25/00 10:26:25 AM
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Network programming in C++
Hi.
I'm trying to port my networking routines to C++, but it doesn't seem to work. I'm using something like
try:
(Cast MySocket to type sockaddr instead of sockaddr_in)
Mark Collins (aka Nurgle)
me@thisisnurgle.org.uk
struct sockaddr_in *MySocket;int SocketHandleMySocket->sin_port=22333;// protocol_number is set correctlySocketHandle=socket( AF_INET, SOCK_STREAM, protocol_number );bind( SocketHandle, (sockaddr *)MySocket, sizeof( MySocket ) );
(Cast MySocket to type sockaddr instead of sockaddr_in)
Mark Collins (aka Nurgle)
me@thisisnurgle.org.uk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement