tcp: Add APICall trace entry and move TRACEs into locked parts.
[haiku.git] / src / add-ons / print / transports / shared / Socket.h
blob6c8a25db16fc176b23b66696ca676cc9d35d1d45
1 // Sun, 18 Jun 2000
2 // Y.Takagi
4 #ifndef __Socket_H
5 #define __Socket_H
7 #include <iostream>
9 #include <string>
11 #if (!__MWERKS__)
12 using namespace std;
13 #else
14 #define std
15 #endif
17 class Socket {
18 public:
19 Socket(const char *host, int port);
20 Socket(const char *host, int port, int localPort);
21 ~Socket();
23 bool operator !() const;
24 bool good() const;
25 bool fail() const;
27 void close();
28 int read(char *buffer, int size, int flags = 0);
29 int write(const char *buffer, int size, int flags = 0);
31 istream &getInputStream();
32 ostream &getOutputStream();
34 int getPort() const;
35 const char *getLastError() const;
37 private:
38 Socket(const Socket &);
39 Socket &operator = (const Socket &);
40 void open();
42 string __host;
43 int __port;
44 int __localPort;
45 int __sock;
46 istream *__is;
47 ostream *__os;
48 bool __error;
49 char __error_msg[256];
52 inline int Socket::getPort() const
54 return __port;
57 inline const char *Socket::getLastError() const
59 return __error_msg;
62 #endif // __Socket_H