G
Guest
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
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