summaryrefslogtreecommitdiff
path: root/include/Socket.h
blob: f65c214a0e9a0ad236c167c9507d1b51127dbdbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef __SOCKET_H__
#define __SOCKET_H__

#include <Handle.h>
#include <BString.h>
#include <Output.h>
#include <Input.h>
#include <Exceptions.h>

class Socket : public Handle {
  public:
      Socket() throw (GeneralException);
      Socket(const Socket &);
      virtual ~Socket() { if (!IsClosed()) { nclose(); tagclose(); } }
    bool SetLocal(const String &, int = 0);
    bool Connect(const String &, int);
    bool Listen();
    Socket Accept() throw (GeneralException);
    bool IsConnected();
    bool IsConnecting();
    bool IsListening();
    virtual bool CanRead();
    virtual bool CanWrite();
    virtual String GetName();
    int GetPort();
    void CloseWrite();
    void CloseRead();
    bool FinalizeConnect();
  protected:
    virtual ssize_t nwrite(const void *, size_t) throw (GeneralException);
    virtual ssize_t nread(void *, size_t) throw (GeneralException);
    virtual int ndup() const throw (GeneralException);
    virtual int nclose() throw (GeneralException);

  private:
      Socket(int s);
    bool connected, listening, writeclosed, readclosed, connecting;
};

#endif