/*  Class for handling sockets in the Internet domain.
 *
 *  Copyright (c) 1996 Aleksey Sudakov <zander@cnext.crec.mipt.ru>.
 *
 *  This software is subject to the terms of the MiscKit license
 *  agreement. Refer to the license document included with the
 *  MiscKit distribution for these terms.
 *
 *  Version 1.0 BETA (16 December 1995)
 */

/*
#import <misckit/MiscSocket.h>
#import <misckit/MiscINETAddress.h>
*/
#import "MiscSocket.h"
#import "MiscINETAddress.h"

@class NSData;
@class NSMutableData;

@interface MiscINETSocket:MiscSocket
{
	MiscINETAddress *localAddress;
	int localPortNum;
	MiscINETAddress *remoteAddress;
	int remotePortNum;
}

+ sendDgram:(void *)data length:(int)dlen to:(MiscINETAddress *)addr port:(int)portNum;
+ sendDgram:(void *)data length:(int)dlen to:(MiscINETAddress *)addr service:(const char *)service;
+ (int)sendDgram:(void *)data length:(int)dlen to:(MiscINETAddress *)addr port:(int)portNum timeout:(unsigned int)ms retries:(int)retries withReply:(void *)repl length:(int *)rlen;
+ (int)sendDgram:(void *)data length:(int)dlen to:(MiscINETAddress *)addr service:(const char *)service timeout:(unsigned int)ms retries:(int)retries withReply:(void *)repl length:(int *)rlen;

#ifndef WIN32
+ (int)ping:(MiscINETAddress *)addr timeout:(unsigned int)ms useECHO:(BOOL)aBool;
#endif

+ runServer:(id)sockets target:(id)target action:(SEL)action fork:(BOOL)fFlag loop:(BOOL)lFlag;
+ runServerPort:(int *)port type:(int)aType action:(SEL)action fork:(BOOL)fFlag loop:(BOOL)lFlag;

- (int)acceptNewConnection:(MiscINETSocket *)newSocket timeout:(unsigned int)ms;
- connectTo:(MiscINETAddress *)addr port:(int)portNum type:(int)aType;
- connectTo:(MiscINETAddress *)addr service:(const char *)service type:(int)aType;

- init;
- initWithCoder:(NSCoder *)coder;
- (void)encodeWithCoder:(NSCoder *)coder;

- copy;
- copyWithZone:(NSZone*)zone;

- openServerPort:(int *)portNum type:(int)aType;
- openServerService:(const char *)service type:(int)aType;

- (int)receiveData:(void *)data length:(int *)dlen;
- (int)receiveData:(void *)data length:(int *)dlen timeout:(unsigned int)ms from:(MiscINETAddress *)addr port:(int *)port;
- (int)receiveData:(void *)data length:(int *)dlen timeout:(unsigned int)ms toNext:(unsigned char)sentinel;
- (int)receiveData:(NSMutableData *)data;
- sendData:(void *)data length:(int)dlen;
- sendData:(NSData *)data;

- shutdownLocalEnd;
- shutdownRemoteEnd;

- enableDebug:(BOOL)aBool;
- (BOOL)debugEnabled;
- enableDelay:(BOOL)aBool;
- (BOOL)delayEnabled;
- enableKeepAlive:(BOOL)aBool;
- (BOOL)keepAliveEnabled;
- setLingerTime:(int)secs;
- (int)lingerTime;

- (BOOL)dataAvailable;
- (MiscINETAddress *)localAddress;
- (int)localPortNum;
- (MiscINETAddress *)remoteAddress;
- (int)remotePortNum;
- (int)socketError;

@end
//
//	TODO:		Get rid of HashTable in -runServer:(id)sockets target:(id)target action:(SEL)action fork:(BOOL)fFlag loop:(BOOL)lFlag
//
