Hello Esteemed Developers
I am trying to develop basic TCP/IP Server-Client programs at the Visual C++ .NET, using Windows Forms Application(.NET) template. I coded the following code snippets
FORM1.
--------------------------------------------------------------------------------------------------------------------
public __gc class Form1 : public System::Windows::Forms::For
..
public
#define PORT 2222
#define IP_Addr "127.0.0.1
SOCKET ServerSocket, ClientSocket
sockaddr_in ServerSockAddrIn, ClientSockAddrIn
WSADATA wsaData
WORD wVersionRequested
int retBindVal, retListenVal, retSendVal, retRecvVal, ClientSockAddrInLen
..
public: void Start_Server()
..
--------------------------------------------------------------------------------------------------------------------
FORM1.cp
--------------------------------------------------------------------------------------------------------------------
void Form1::Start_Server(
...
retBindVal = bind(ServerSocket,(sockaddr*) &ServerSockAddrIn, sizeof(ServerSockAddrIn)); //Error Msg #
..
ClientSocket = accept(ServerSocket, (struct sockaddr*) &ClientSockAddrIn, &ClientSockAddrInLen); //Error Msg #
..
--------------------------------------------------------------------------------------------------------------------
When I build the application it gives me the following error
Error Msg #1: errorC2440: 'type cast' : cannot convert from 'sockaddr_in __gc*' to 'sockaddr*
Error Msg #2: errorC2440: 'type cast' : cannot convert from 'sockaddr_in __gc*' to 'sockaddr*
I guess that I should type cast unmanaged code to managed code. Please kindly guide me to solve this problem. I downloaded VC.NET Samples from microsoft.com. There are Socket samples in it, but they are not clear for me
I am requesting your kind helps
Thank you very much
auburnate - 28 May 2004 18:58 GMT
I'm also interested in fixing this error. Does anyone know how t
convert from 'unsigned short [19]' to 'char' .
Nat
-
auburnat
David Olsen - 29 May 2004 01:02 GMT
> I'm also interested in fixing this error. Does anyone know how to
> convert from 'unsigned short [19]' to 'char' .
There is no meaningful conversion from 'unsigned short [19]' to 'char'.
To be of any help, we need to know what kind of object you have, and why
the compiler thinks it needs to convert it to 'char'.

Signature
David Olsen
qg4h9ykc5m@yahoo.com