🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages Started by Boguslaw Fries Sat, 08 Mar 2003 19:38
getsockopt
#17655
Author: Boguslaw Fries
Date: Sat, 08 Mar 2003 19:38
12 lines
1301 bytes
I have  question concerning getsockopt
I have a valid ( I hope ) pointer to a socket
the function getsocketname( s , SOCKADDR * ) &ame strlen( SOCKADDR_IN ))
returns proper name i.e  IP and port are correct

but
int sockType,
 getsockopt( s , SOL_SOCKET , SO_TYPE,  ( char FAR * ) &sockType, sizeof(
sockType ))
 returns invalid type - sockType == 2  but should be 1 ( TCP not UDP )
what is wrong??
Boguslaw Fries
Re: getsockopt
#17658
Author: Remy Lebeau (TeamB)
Date: Sat, 08 Mar 2003 21:39
25 lines
1735 bytes
Did you test the return value of getsockopt() to make sure it even succeeded
to begin with?  You should also initialize your int variable, otherwise it
will get a random value, which if getsockopt() fails, your code will
interpret incorrectly:

    int sockType = 0,
    if( getsockopt(s , SOL_SOCKET , SO_TYPE,  (char FAR *)&sockType,
sizeof(sockType) == 0 )
        // use sockType as needed
    else
        // error

Also, how are you creating/retreiving the socket descriptor to begin with?


Gambit

"Boguslaw Fries" <B.Fries@luca-online.de> wrote in message
news:3e6a47b9@newsgroups.borland.com...

> int sockType,
>  getsockopt( s , SOL_SOCKET , SO_TYPE,
> ( char FAR * ) &sockType, sizeof( sockType ))
>  returns invalid type - sockType == 2  but should be 1
> ( TCP not UDP )
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads