A couple of methods added for consistency.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19880 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-08-18 10:12:13 +00:00
parent b42cad5549
commit 4e65c1501f
4 changed files with 59 additions and 0 deletions

View file

@ -2331,6 +2331,41 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
return address;
}
- (NSString*) socketLocalAddress
{
NSString *str = nil;
struct sockaddr_in sin;
int size = sizeof(sin);
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
{
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
}
else
{
str = [NSString stringWithCString: (char*)inet_ntoa(sin.sin_addr)];
}
return str;
}
- (NSString*) socketLocalService
{
NSString *str = nil;
struct sockaddr_in sin;
int size = sizeof(sin);
if (getsockname(descriptor, (struct sockaddr*)&sin, &size) == SOCKET_ERROR)
{
NSLog(@"unable to get socket name - %s", GSLastErrorStr(errno));
}
else
{
str = [NSString stringWithFormat: @"%d",
(int)GSSwapBigI16ToHost(sin.sin_port)];
}
return str;
}
- (NSString*) socketProtocol
{
return protocol;

View file

@ -613,6 +613,22 @@ NSString * const NSFileHandleOperationException
return nil;
}
/**
* Returns the local address of the network connection or nil.
*/
- (NSString*) socketLocalAddress
{
return nil;
}
/**
* Returns the local service/port of the network connection or nil.
*/
- (NSString*) socketLocalService
{
return nil;
}
/**
* Returns the name (or number) of the service (network port) in use for
* the network connection represented by the file handle.