Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

How to handle 'error C2440'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alper AKcayoz - 14 May 2004 10:16 GMT
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


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.