Jump to content
  • Advertisement
Sign in to follow this  
Genjix

My client doesnt work.

This topic is 5022 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Simple client on Linux to connect to my server to recieve string.

	their_addr.sin_addr = (struct in_addr)he->h_addr;
Why doesn't the compiler allow this cast (the includes show sin_addr is an in_addr). What can I do to resolve it?

recv.c: In function `main':
recv.c:54: error: conversion to non-scalar type requested

Share this post


Link to post
Share on other sites
Advertisement
This is a general programming cast.

sin_addr is a struct, and you can't cast from struct type to other struct type. You can, however, cast to reference type(!) so this ought to work:

their_addr.sin_addr = (struct in_addr &)he->h_addr;

Share this post


Link to post
Share on other sites
genjix@linux:~/socket> gcc recv.c
recv.c: In function `main':
recv.c:37: error: parse error before '&' token

:(

Share this post


Link to post
Share on other sites
Quote:
Original post by Genjix
genjix@linux:~/socket> gcc recv.c
recv.c: In function `main':
recv.c:37: error: parse error before '&' token

:(
Since it's a parse error you need to post the code...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just guessing (sort of), but:
their_addr.sin_addr.s_addr = he->h_addr;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!