Click to See Complete Forum and Search --> : Eureka I think.


ccubed
June 27th, 2007, 12:19 AM
I found out where the Access Violation is. Thing is, i'm not usre why it's wrong. What's wrong with this code.


LPHostEnt = gethostbyname(address.c_str());
sin.sin_family = AF_INET;
sin.sin_addr = *((LPIN_ADDR)*LPHostEnt->h_addr_list);
sin.sin_port=htons(port);


The part in bold is where the problem is. also, LPHostEnt is a member of NSock. so, NSock.LPHostEnt. Here's the private part of NSock. The above is also a function within NSock.


int port;
int datasize;
int error_ret;
LPHOSTENT LPHostEnt;
WSADATA WsaData;
WORD WVer;
std::string address;
SOCKET Nova;
int MXBUFA;
struct sockaddr_in sin;

MikeAThon
June 27th, 2007, 11:48 AM
Try
sin.sin_addr = *((struct in_addr *)LPHostEnt->h_addr);
Mike

PS: Is this the answer to your other post at http://www.codeguru.com/forum/showthread.php?t=427050

It would be better to keep your related posts together.

ccubed
June 27th, 2007, 02:22 PM
Okay, i'll take your advice and only use this thread from now on. I fixed the LPHostEnt problem, your solution worked dreams, but now I have another problem. Ok, for those of you that don't know, a mu* is a text based rpg. It's basically like a chat program with an rpg added for fun. Now, my program connects to any mu* i ask it to just fine, my problem comes after I receive the intro. For instance, the first recv call works fine and i've set it to receive 10kb max so it never stops mid intro, but afterwards, when I send data, the recv call just stops and hangs. I've read about this being a common problem and was wondering if anyone had any idea. Conincidentily it happens right after i try to connect to my character.