/***************************************************************************
                            QSocket.java -  description
                             -------------------
    begin                : Wed Nov 21 17:05:56 2001
    copyright            : (C) 2000-2001 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Wed Nov 21 17:05:56 2001, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
***************************************************************************/

package org.kde.qt;

import java.util.*;
import java.lang.Error;

/**
 See {@link QSocketSignals} for signals emitted by QSocket.

 See {@link QSocketEventHandling} for event handlers to override in subclasses of QSocket.

*/
public class QSocket extends QObject implements  QIODeviceInterface {
	protected QSocket(Class dummy){super((Class) null);}

	private native void newQSocket( QObject parent, String name);
	public QSocket( QObject parent, String name) {
		super((Class) null);
		newQSocket( parent, name);
	}
	private native void newQSocket();
	public QSocket() {
		super((Class) null);
		newQSocket();
	}
	protected native void finalize() throws InternalError;
	public native int state();
	public native int socket();
	public native void setSocket( int arg1);
	public native QSocketDevice socketDevice();
	public native void setSocketDevice( QSocketDevice arg1);
	public native void connectToHost( String host, short port);
	public native String peerName();
	public native boolean open( int mode);
	public native void close();
	public native void flush();
	public native int size();
	public native int at();
	public native boolean at( int arg1);
	public native boolean atEnd();
	public native long bytesAvailable();
	public native long waitForMore( int msecs);
	public native long bytesToWrite();
	public native long readBlock( StringBuffer data, long maxlen);
	public native long writeBlock( String data, long len);
	public native long readLine( StringBuffer data, long maxlen);
	public native int getch();
	public native int putch( int arg1);
	public native int ungetch( int arg1);
	public native boolean canReadLine();
	public native String readLine();
	public native short port();
	public native short peerPort();
	public native QHostAddress address();
	public native QHostAddress peerAddress();
	protected native void sn_read( boolean force);
	protected native void sn_read();
	protected native void sn_write();
	
	// From QIODeviceInterface
	public native int flags();
	public native int mode();
	public native boolean isDirectAccess();
	public native boolean isSequentialAccess();
	public native boolean isCombinedAccess();
	public native boolean isBuffered();
	public native boolean isRaw();
	public native boolean isSynchronous();
	public native boolean isAsynchronous();
	public native boolean isTranslated();
	public native boolean isReadable();
	public native boolean isWritable();
	public native boolean isReadWrite();
	public native boolean isInactive();
	public native boolean isOpen();
	public native int status();
	public native void resetStatus();
	public native boolean reset();
	public native long writeBlock( byte[] data);
	public native byte[] readAll();
	
	public static final int ErrConnectionRefused = 0;
	public static final int ErrHostNotFound = 1;
	public static final int ErrSocketRead = 2;
	public static final int Idle = 0;
	public static final int HostLookup = 1;
	public static final int Connecting = 2;
	public static final int Connected = 3;
	public static final int Closing = 4;
	public static final int Connection = Connected;
}
