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:
Richard Frith-Macdonald 2004-08-18 10:12:13 +00:00
parent b6706ad3bc
commit 284ce516b8
4 changed files with 59 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2004-08-18 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSFileHandle.m: Add methods to get local socket info
matching mthe existing methods which return remote address/port.
* Source/GSFileHandle.m: ditto.
2004-08-17 David Ayers <d.ayers@inode.at> 2004-08-17 David Ayers <d.ayers@inode.at>
* Testing/GNUmakefile: Reactivate nsinvocation test. * Testing/GNUmakefile: Reactivate nsinvocation test.

View file

@ -182,6 +182,8 @@ GS_EXPORT NSString * const NSFileHandleOperationException;
forModes: (NSArray*)modes; forModes: (NSArray*)modes;
- (BOOL) readInProgress; - (BOOL) readInProgress;
- (NSString*) socketAddress; - (NSString*) socketAddress;
- (NSString*) socketLocalAddress;
- (NSString*) socketLocalService;
- (NSString*) socketService; - (NSString*) socketService;
- (NSString*) socketProtocol; - (NSString*) socketProtocol;
- (BOOL) useCompression; - (BOOL) useCompression;

View file

@ -2331,6 +2331,41 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
return address; 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 - (NSString*) socketProtocol
{ {
return protocol; return protocol;

View file

@ -613,6 +613,22 @@ NSString * const NSFileHandleOperationException
return nil; 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 * Returns the name (or number) of the service (network port) in use for
* the network connection represented by the file handle. * the network connection represented by the file handle.