70 SoDispCon_ExTypeRead=1,
71 SoDispCon_ExTypeWrite,
72 SoDispCon_GetSharkSslCon,
73 SoDispCon_ExTypeClose,
74 SoDispCon_ExTypeMoveCon,
75 SoDispCon_ExTypeAllocAsynchBuf,
76 SoDispCon_ExTypeAsyncReady,
99typedef int (*SoDispCon_Execute)(
103typedef void (*SoDispCon_DispRecEv)(
struct SoDispCon* con);
104typedef void (*SoDispCon_DispSendEv)(
struct SoDispCon* con);
114 void *
operator new(size_t,
void *place) {
return place; }
115 void operator delete(
void*,
void *) { }
134 const void* bindIntfName=0,
137 BaBool dgram=
false, BaBool ipv6=
false,
169 char*
addr2String(HttpSockaddr* addr,
char* buf,
int len);
173 bool cmpAddr(HttpSockaddr* addr2);
203 void setDispSendEvent(SoDispCon_DispSendEv ev);
204 void setDispRecEvent(SoDispCon_DispRecEv ev);
205 int readData(
void* data,
int len,
bool relmutex=
false);
206 int setNonblocking();
208 int sendData(
const void* data,
int len);
209 int asyncSend(
int len);
210 int sendChunkData(
const void* data,
int len);
212 void* allocAsynchBuf(
int* size);
214 CONNECTION_DISPATCHER_OBJ
218 SoDispCon_Execute exec;
220 HttpSocket httpSocket;
221 SoDispCon_DispRecEv dispRecEv;
222 SoDispCon_DispSendEv dispSendEv;
223 struct SoDisp* dispatcher;
231#define SoDispCon_socketHasNonBlockDataBitMask 0x01
232#define SoDispCon_hasMoreDataDataBitMask 0x02
234#define SoDispCon_dispatcherHasConDataBitMask 0x04
235#define SoDispCon_recEvActiveDataBitMask 0x08
236#define SoDispCon_sendEvActiveDataBitMask 0x10
237#define SoDispCon_isNonBlockingDataBitMask 0x20
238#define SoDispCon_IP6DataBitMask 0x40
239#define SoDispCon_DGramBitMask 0x80
241#define SoDispCon_setDispHasRecData(o)\
243 (SoDispCon_hasMoreDataDataBitMask | SoDispCon_socketHasNonBlockDataBitMask))
244#define SoDispCon_setDispatcherHasCon(o)\
245 ((o)->dataBits |= SoDispCon_dispatcherHasConDataBitMask)
246#define SoDispCon_setRecEvActive(o)\
247 ((o)->dataBits |= SoDispCon_recEvActiveDataBitMask)
248#define SoDispCon_setSendEvActive(o)\
249 ((o)->dataBits |= SoDispCon_sendEvActiveDataBitMask)
250#define SoDispCon_setIP6(o)\
251 ((o)->dataBits |= SoDispCon_IP6DataBitMask)
253#define SoDispCon_clearSocketHasNonBlockData(o)\
254 ((o)->dataBits &= ~(U8)SoDispCon_socketHasNonBlockDataBitMask)
255#define SoDispCon_clearHasMoreData(o)\
256 ((o)->dataBits &= ~(U8)SoDispCon_hasMoreDataDataBitMask)
257#define SoDispCon_clearDispatcherHasCon(o)\
258 ((o)->dataBits &= ~(U8)SoDispCon_dispatcherHasConDataBitMask)
259#define SoDispCon_setRecEvInactive(o)\
260 ((o)->dataBits &= ~(U8)SoDispCon_recEvActiveDataBitMask)
261#define SoDispCon_setSendEvInactive(o)\
262 ((o)->dataBits &= ~(U8)SoDispCon_sendEvActiveDataBitMask)
263#define SoDispCon_clearIP6(o)\
264 ((o)->dataBits &= ~(U8)SoDispCon_IP6DataBitMask)
266#define SoDispCon_socketHasNonBlockData(o)\
267 (((o)->dataBits & SoDispCon_socketHasNonBlockDataBitMask) ? TRUE : FALSE)
268#define SoDispCon_hasMoreData(o)\
269 (((o)->dataBits & SoDispCon_hasMoreDataDataBitMask) ? TRUE : FALSE)
270#define SoDispCon_dispatcherHasCon(o)\
271 (((o)->dataBits & SoDispCon_dispatcherHasConDataBitMask)?TRUE:FALSE)
272#define SoDispCon_recEvActive(o)\
273 (((o)->dataBits & SoDispCon_recEvActiveDataBitMask)?TRUE:FALSE)
274#define SoDispCon_sendEvActive(o)\
275 (((o)->dataBits & SoDispCon_sendEvActiveDataBitMask)?TRUE:FALSE)
276#define SoDispCon_isNonBlocking(o)\
277 (((o)->dataBits & SoDispCon_isNonBlockingDataBitMask) ? TRUE : FALSE)
278#ifndef SoDispCon_isIP6
279#define SoDispCon_isIP6(o)\
280 (((o)->dataBits & SoDispCon_IP6DataBitMask) ? TRUE : FALSE)
281#define SoDispCon_isDGRAM(o) \
282 (((o)->dataBits & SoDispCon_DGramBitMask) ? TRUE : FALSE)
284#define SoDispCon_isSecure(o) \
285 ((o)->exec(o,0,SoDispCon_GetSharkSslCon,0,0) > 0)
286#define SoDispCon_getSharkSslCon(o,sharkSslConPtrPtr) \
287 (o)->exec(o,0,SoDispCon_GetSharkSslCon,sharkSslConPtrPtr,0)
288#define SoDispCon_isValid(o) HttpSocket_isValid(&(o)->httpSocket)
289#define SoDispCon_invalidate(o) HttpSocket_invalidate(&(o)->httpSocket)
290#define SoDispCon_getDispatcher(o) (o)->dispatcher
291#define SoDispCon_dispRecEvent(o) (o)->dispRecEv(o)
292#define SoDispCon_dispSendEvent(o) (o)->dispSendEv(o)
293#define SoDispCon_setDispSendEvent(o, dispSendEvFp) \
294 (o)->dispSendEv=dispSendEvFp
296#define SoDispCon_setDispRecEvent(o, dispRecEvFp) \
297 (o)->dispRecEv=dispRecEvFp
299#define SoDispCon_readData(o, data, len, relmutex) \
300 (o)->exec(o, (relmutex) ? SoDisp_getMutex((o)->dispatcher) : 0, \
301 SoDispCon_ExTypeRead,data,len)
309#ifndef SoDispCon_newConnectionIsReady
310#define SoDispCon_newConnectionIsReady(con)
313BA_API
int SoDispCon_getSharkAlert(
314 SoDispCon* o, U8* alertLevel, U8* alertDescription);
319BA_API
void SoDispCon_constructor(
321BA_API
int SoDispCon_upgrade(
SoDispCon* o,
struct SharkSsl* ssl,
322 const char* alpn,
const char* host,
int port);
323BA_API
int SoDispCon_blockRead(
SoDispCon* o,
void* data,
int len);
324BA_API
int SoDispCon_sendData(
SoDispCon* o,
const void* data,
int len);
325BA_API
int SoDispCon_sendDataNT(
SoDispCon* o,
const void* data,
int len);
326BA_API
int SoDispCon_sendDataX(
SoDispCon* o,
const void* data,
int len);
327BA_API
int SoDispCon_sendChunkData(
SoDispCon* o,
const void* data,
int len);
328BA_API
int SoDispCon_asyncReadyF(
SoDispCon* o);
329#define SoDispCon_asyncReady(o)\
330 (o)->exec(o,0,SoDispCon_ExTypeAsyncReady,0,0)
331#define SoDispCon_asyncSend(o, len) \
332 (o)->exec(o,0,SoDispCon_ExTypeAsyncReady,0,len)
343BA_API
void* SoDispCon_allocAsynchBuf(
SoDispCon* o,
int* size);
344BA_API
void SoDispCon_releaseAsyncBuf(
SoDispCon* con);
345BA_API
void SoDispCon_internalAllocAsynchBuf(
346 SoDispCon* con, AllocAsynchBufArgs* args);
347BA_API
int SoDispCon_setNonblocking(
SoDispCon* o);
348BA_API
int SoDispCon_setBlocking(
SoDispCon* o);
351#define SoDispCon_destructor(o) SoDispCon_zzCloseCon(o,1)
352#define SoDispCon_hardClose(o) SoDispCon_zzCloseCon(o, 2)
353#define SoDispCon_shutdown(o) SoDispCon_zzCloseCon(o, 1)
354#define SoDispCon_closeCon(o) SoDispCon_zzCloseCon(o, 0)
355#define SoDispCon_setReadTmo(o,timeout) (o)->rtmo = (U16)((timeout)/50)
356BA_API
void SoDispCon_zzCloseCon(
SoDispCon* o,
int shutdown);
357BA_API
void SoDispCon_setTCPNoDelay(
SoDispCon* o,
int enable);
358BA_API
int SoDispCon_getPeerName(
SoDispCon* o,HttpSockaddr* addr,U16* port);
359BA_API
int SoDispCon_getSockName(
SoDispCon* o, HttpSockaddr* addr, U16* port);
360BA_API
char* SoDispCon_addr2String(
361 SoDispCon* o, HttpSockaddr* addr,
char* buf,
int len);
362BA_API BaBool SoDispCon_cmpAddr(
SoDispCon* o, HttpSockaddr* addr2);
363BA_API
void SoDispCon_printSockErr(
364 SoDispCon* o,
const char* type,HttpSocket* s,
int status);
365#define SoDispCon_getId(o) HttpSocket_getId(&(o)->httpSocket)
367#ifndef SoDispCon_platReadData
369 void* data,
int len);
376 const void* bindIntfName,
379 BaBool dgram, BaBool ipv6,
381#ifndef NO_ASYNCH_RESP
386 const void* bindIntfName,
389BA_API
int SoDispCon_asyncConnectNext(
SoDispCon* o);
391BA_API
void SoDispCon_asyncConnectRelease(
SoDispCon* o);
393#define SoDispCon_asyncConnectRelease(o)
399inline int SoDispCon::readData(
void* data,
int len,
bool relmutex) {
400 return SoDispCon_readData(
this, data, len, relmutex ? TRUE : FALSE); }
401inline int SoDispCon::setNonblocking() {
402 return SoDispCon_setNonblocking(
this); }
403inline int SoDispCon::setBlocking() {
404 return SoDispCon_setBlocking(
this); }
406 return SoDispCon_isSecure(
this) ? true :
false; }
408 return SoDispCon_getSharkSslCon(
this,sc) ? true :
false; }
410 return SoDispCon_isIP6(
this) ? true :
false; }
412 return SoDispCon_isValid(
this) ? true :
false; }
414 return SoDispCon_getPeerName(
this,addr,port); }
416 return SoDispCon_getSockName(
this, addr,port); }
418 return SoDispCon_addr2String(
this, addr, buf, len); }
420 return SoDispCon_cmpAddr(
this, addr2) ? true :
false;
423 SoDispCon_setTCPNoDelay(
this, enable); }
425 return SoDispCon_hasMoreData(
this) ? true :
false;
428 return SoDispCon_dispatcherHasCon(
this) ? true :
false; }
430 return SoDispCon_recEvActive(
this) ? true :
false; }
432 return SoDispCon_sendEvActive(
this) ? true :
false; }
434 return SoDispCon_getDispatcher(
this); }
435inline void SoDispCon::setDispSendEvent(SoDispCon_DispSendEv ev) {
436 SoDispCon_setDispSendEvent(
this, ev); }
437inline void SoDispCon::setDispRecEvent(SoDispCon_DispRecEv ev) {
438 SoDispCon_setDispRecEvent(
this, ev); }
439inline int SoDispCon::sendData(
const void* data,
int len) {
440 return SoDispCon_sendData(
this,data, len); }
441inline int SoDispCon::asyncSend(
int len) {
442 return SoDispCon_asyncSend(
this, len); }
443inline int SoDispCon::sendChunkData(
const void* data,
int len) {
444 return SoDispCon_sendChunkData(
this, data, len); }
445inline int SoDispCon::asyncReady() {
446 return SoDispCon_asyncReadyF(
this) ? true :
false; }
447inline void* SoDispCon::allocAsynchBuf(
int* size){
448 return SoDispCon_allocAsynchBuf(
this, size); }
451 const void* bindIntfName,
454 BaBool dgram, BaBool ipv6,
456 return SoDispCon_connect(
this,host,port, bindIntfName,bindPort,timeout,
457 dgram?TRUE:FALSE, dgram?TRUE:FALSE,errinfo);
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:83
Contains information about the physical socket connection.
Definition: SoDispCon.h:112
int connect(const char *host, U16 port, const void *bindIntfName=0, U16 bindPort=0, U32 timeout=1500, BaBool dgram=false, BaBool ipv6=false, char **errinfo=0)
Connect to host/IP address.
Definition: SoDispCon.h:449
struct SoDisp * getDispatcher()
Fetch the SoDisp object.
Definition: SoDispCon.h:433
bool isIP6()
Returns true if this is an IP version 6 connection.
Definition: SoDispCon.h:409
bool isValid()
Returns true if the socket connection is valid.
Definition: SoDispCon.h:411
bool isSecure()
Deprecated: Use getSharkSslCon(NULL).
Definition: SoDispCon.h:405
bool sendEvActive()
Used for non blocking send.
Definition: SoDispCon.h:431
char * addr2String(HttpSockaddr *addr, char *buf, int len)
Converts IP address to string.
Definition: SoDispCon.h:417
bool cmpAddr(HttpSockaddr *addr2)
Compare addr with address returned by getPeerName.
Definition: SoDispCon.h:419
bool getSharkSslCon(SharkSslCon **sc)
Returns true if this is an SSL connection.
Definition: SoDispCon.h:407
void setTCPNoDelay(bool enable)
Disable the TCP delay.
Definition: SoDispCon.h:422
bool hasMoreData()
Returns true if more data on the socket.
Definition: SoDispCon.h:424
bool recEvActive()
Returns true if the connection is active in the SoDisp object.
Definition: SoDispCon.h:429
int getSockName(HttpSockaddr *addr, U16 *port=0)
Returns the 'sock' IP address.
Definition: SoDispCon.h:415
bool dispatcherHasCon()
Returns true if connection is in the SoDisp object.
Definition: SoDispCon.h:427
int getPeerName(HttpSockaddr *addr, U16 *port=0)
Returns the 'peer' IP address.
Definition: SoDispCon.h:413
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:86
A mutual exclusion class.
Definition: ThreadLib.h:186