Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
problem being faced in using winsock2's setsockopt function Posted by Rizwan Rafique on 28 Nov 2001 at 10:41 AM
int TimeOut, valsize;
setsockopt(skt,SOL_SOCKET,SO_RCVTIMEO,(const char *)&TimeOut,valsize);

firstly i make the call with TimeOut = 1000 and valsize = sizeof(TimeOut), then i make it with TimeOut = 0 and valsize=0

the first call ends up sucessfully but the second one doesnt

it gives an erorr of WSAEFAULT
(the description of error from MSDN
optval is not in a valid part of the process address space or optlen parameter is too small

optval=TimeOut, optlen = valsize

anyone who can help??
Report
Re: problem being faced in using winsock2's setsockopt function Posted by Darius on 28 Nov 2001 at 4:15 PM
: int TimeOut, valsize;
: setsockopt(skt,SOL_SOCKET,SO_RCVTIMEO,(const char *)&TimeOut,valsize);
:
: firstly i make the call with TimeOut = 1000 and valsize = sizeof(TimeOut), then i make it with TimeOut = 0 and valsize=0
:
: the first call ends up sucessfully but the second one doesnt
:
: it gives an erorr of WSAEFAULT
: (the description of error from MSDN
: optval is not in a valid part of the process address space or optlen parameter is too small
:
: optval=TimeOut, optlen = valsize
:
: anyone who can help??
:

First casting the address of an integer to a const char * does not seem like a good idea. Next, TimeOut is the same size no matter what it's value is, so you probably still need valsize=sizeof(TimeOut). If you mean to have TimeOut a NULL pointer then simply put NULL there, if you won't know this until runtime, then use a pointer variable.

"Faith alone, won't sustain us anymore."
-Faith Alone, Bad Religion




 

Recent Jobs