Sign in to follow this  

My client doesnt work.

This topic is 4717 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
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
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

This topic is 4717 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this