@@ -22,7 +22,6 @@ CIOCPSocket2::CIOCPSocket2()
2222 m_Socket = INVALID_SOCKET ;
2323
2424 m_pIOCPort = nullptr ;
25- m_Type = TYPE_ACCEPT ;
2625}
2726
2827CIOCPSocket2::~CIOCPSocket2 ()
@@ -54,49 +53,6 @@ bool CIOCPSocket2::Create(UINT nSocketPort, int nSocketType, long lEvent, const
5453 return true ;
5554}
5655
57- bool CIOCPSocket2::Connect (CIOCPort* pIocp, const char * lpszHostAddress, UINT nHostPort)
58- {
59- sockaddr_in addr;
60-
61- memset (&addr, 0 , sizeof (addr));
62- addr.sin_family = AF_INET ;
63- addr.sin_addr .s_addr = inet_addr (lpszHostAddress);
64- addr.sin_port = htons (nHostPort);
65-
66- int result = connect (m_Socket, (sockaddr*) &addr, sizeof (addr));
67- if (result == SOCKET_ERROR )
68- {
69- int err = WSAGetLastError ();
70- // TRACE("CONNECT FAIL : %d\n", err);
71- closesocket (m_Socket);
72- return false ;
73- }
74-
75- ASSERT (pIocp);
76-
77- InitSocket (pIocp);
78-
79- m_Sid = m_pIOCPort->GetClientSid ();
80- if (m_Sid < 0 )
81- return false ;
82-
83- m_pIOCPort->m_ClientSockArray [m_Sid] = this ;
84-
85- if (!m_pIOCPort->Associate (this , m_pIOCPort->m_hClientIOCPort ))
86- {
87- spdlog::error (" IOCPSocket2::Connect: failed to associate" );
88- return false ;
89- }
90-
91- m_ConnectAddress = lpszHostAddress;
92- m_State = STATE_CONNECTED ;
93- m_Type = TYPE_CONNECT ;
94-
95- Receive ();
96-
97- return true ;
98- }
99-
10056int CIOCPSocket2::Send (char * pBuf, long length, int dwFlag)
10157{
10258 int ret_value = 0 ;
@@ -172,11 +128,7 @@ int CIOCPSocket2::Send(char* pBuf, long length, int dwFlag)
172128 pOvl = &m_RecvOverlapped;
173129 pOvl->Offset = OVL_CLOSE ;
174130
175- if (m_Type == TYPE_ACCEPT )
176- hComport = m_pIOCPort->m_hServerIOCPort ;
177- else
178- hComport = m_pIOCPort->m_hClientIOCPort ;
179-
131+ hComport = m_pIOCPort->m_hServerIOCPort ;
180132 PostQueuedCompletionStatus (hComport, 0 , m_Sid, pOvl);
181133
182134 return -1 ;
@@ -237,11 +189,7 @@ int CIOCPSocket2::Receive()
237189 pOvl = &m_RecvOverlapped;
238190 pOvl->Offset = OVL_CLOSE ;
239191
240- if (m_Type == TYPE_ACCEPT )
241- hComport = m_pIOCPort->m_hServerIOCPort ;
242- else
243- hComport = m_pIOCPort->m_hClientIOCPort ;
244-
192+ hComport = m_pIOCPort->m_hServerIOCPort ;
245193 PostQueuedCompletionStatus (hComport, 0 , m_Sid, pOvl);
246194
247195 return -1 ;
@@ -351,27 +299,6 @@ bool CIOCPSocket2::PullOutCore(char*& data, int& length)
351299 return foundCore;
352300}
353301
354- bool CIOCPSocket2::AsyncSelect (long lEvent)
355- {
356- int retEventResult, err;
357-
358- retEventResult = WSAEventSelect (m_Socket, m_hSockEvent, lEvent);
359- err = WSAGetLastError ();
360- return (retEventResult == 0 );
361- }
362-
363- bool CIOCPSocket2::SetSockOpt (int nOptionName, const void * lpOptionValue, int nOptionLen, int nLevel)
364- {
365- int retValue = setsockopt (m_Socket, nLevel, nOptionName, (char *) lpOptionValue, nOptionLen);
366- return (retValue == 0 );
367- }
368-
369- bool CIOCPSocket2::ShutDown (int nHow)
370- {
371- int retValue = shutdown (m_Socket, nHow);
372- return (retValue == 0 );
373- }
374-
375302void CIOCPSocket2::Close ()
376303{
377304 if (m_pIOCPort == nullptr )
@@ -382,10 +309,7 @@ void CIOCPSocket2::Close()
382309 pOvl = &m_RecvOverlapped;
383310 pOvl->Offset = OVL_CLOSE ;
384311
385- if (m_Type == TYPE_ACCEPT )
386- hComport = m_pIOCPort->m_hServerIOCPort ;
387- else
388- hComport = m_pIOCPort->m_hClientIOCPort ;
312+ hComport = m_pIOCPort->m_hServerIOCPort ;
389313
390314 int retValue = PostQueuedCompletionStatus (hComport, 0 , m_Sid, pOvl);
391315 if (retValue == 0 )
0 commit comments