Midtown Computer Systems Enterprise

Convenient web based access to our favorite computer related Usenet groups.
MCSE.MS is not affiliated with Microsoft corporation, Cisco corporation, Oracle, CompTIA or any other vendor.
Check our Computer Hardware forum | Cell Phones reviews

Go Back  MCSE > Microsoft software reviews > Dot Net tutorials > .NET Languages / VC


.NET Languages / VC microsoft.public.dotnet.languages.vc

 
 
Thread Tools Display Modes
  #1  
Old 05-14-04, 09:42 PM
Alper AKcayoz
How to handle 'error C2440'
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.H
---------------------------------------------------------------------------------------------------------------------
public __gc class Form1 : public System::Windows::Forms::Form
{
...
public:
#define PORT 22222
#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.cpp
---------------------------------------------------------------------------------------------------------------------
void Form1::Start_Server()
{
....
retBindVal = bind(ServerSocket,(sockaddr*) &ServerSockAddrIn, sizeof(ServerSockAddrIn)); //Error Msg #1
...
ClientSocket = accept(ServerSocket, (struct sockaddr*) &ClientSockAddrIn, &ClientSockAddrInLen); //Error Msg #2
...
}
---------------------------------------------------------------------------------------------------------------------

When I build the application it gives me the following errors
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
  #2  
Old 05-28-04, 12:58 PM
auburnate auburnate is offline
Junior Member
Join Date: May 2004
Re: How to handle 'error C2440'
I'm also interested in fixing this error.  Does anyone know how to convert from 'unsigned short [19]' to 'char' .

Nate
  #3  
Old 05-28-04, 08:17 PM
David Olsen
Re: How to handle 'error C2440'
auburnate wrote:
> 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'.

--
David Olsen
qg4h9ykc5m@yahoo.com

 


Popular forums
A+ (A Plus) Windows 2000 Active directory Exchange 2000 information store
Network+ Windows XP Security Exchange 2000 server administration
MCSE .NET Web services SQL Server
Cisco certification ASP .NET SQL 2000 Programming
Windows 2000 Registry .NET XML Viruses


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:13 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright MCSE braindumps 2003-2006