OSDN Git Service

GUI終了時のエラー落ちを修正(?)
[peercast-im/PeerCastIM.git] / PeerCast.root / PeerCast / core / win32 / wsocket.h
1 // ------------------------------------------------
2 // File : wsocket.h
3 // Date: 4-apr-2002
4 // Author: giles
5 // Desc: 
6 //              see .cpp for details
7 //              
8 // (c) 2002 peercast.org
9 // ------------------------------------------------
10 // This program is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 2 of the License, or
13 // (at your option) any later version.
14
15 // This program is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 // GNU General Public License for more details.
19 // ------------------------------------------------
20
21 #ifndef _WSOCKET_H
22 #define _WSOCKET_H
23
24 #include <windows.h>
25 #include "socket.h"
26 //#include "winsock2.h"
27
28
29 // --------------------------------------------------
30 class WSAClientSocket : public ClientSocket
31 {
32 public:
33         static void     init();
34
35     WSAClientSocket()
36         :sockNum(0)
37         ,writeCnt(0)
38         ,rbPos(0)
39         ,rbDataSize(0)
40     {
41     }
42
43         ~WSAClientSocket(){
44                 bufList.clear();
45         }
46
47         virtual void    open(Host &);
48         virtual int             read(void *, int);
49         virtual int             readUpto(void *, int);
50         virtual void    write(const void *, int);
51         virtual void    bind(Host &);
52         virtual void    connect();
53         virtual void    close();
54         virtual ClientSocket * accept();
55         virtual bool    active() {return sockNum != 0;}
56         virtual bool    readReady();
57         virtual Host    getLocalHost();
58         virtual void    setBlocking(bool);
59         void    setReuse(bool);
60         void    setNagle(bool);
61         void    setLinger(int);
62         void    setBufSize(int size);
63
64 //      static  HOSTENT         *resolveHost(const char *);
65         static  hostent         *resolveHost(const char *);
66
67         void    checkTimeout(bool,bool);
68         void    checkTimeout2(bool,bool);
69
70         virtual void    bufferingWrite(const void*, int);
71         void    checkBuffering(bool, bool);
72
73         unsigned int writeCnt;
74         unsigned int sockNum;
75         struct sockaddr_in remoteAddr;
76
77         enum {RBSIZE = 8192};
78         char apReadBuf[RBSIZE];
79         int rbPos;
80         int rbDataSize;
81
82         WLock sockLock;
83 };
84
85 #endif
86