74 |
|
|
75 |
#include "monitor.h" |
#include "monitor.h" |
76 |
#include "net.h" |
#include "net.h" |
77 |
|
#include "ssl.h" |
78 |
|
|
79 |
/** |
/** |
80 |
* General purpose Network and Socket methods. |
* General purpose Network and Socket methods. |
448 |
|
|
449 |
} |
} |
450 |
|
|
451 |
|
/** |
452 |
|
* Send the message 'msg' down a port in non-blocking mode and |
453 |
|
* with failover. Uses SSL if necessary. |
454 |
|
* @param p port handler |
455 |
|
* @param msg The message to send |
456 |
|
* @param len The length of the message in bytes |
457 |
|
* @param flags Optional send flags |
458 |
|
* @return The bytes sent or -1 if an error occured |
459 |
|
*/ |
460 |
|
int port_send(Port_T p, const char *msg, int len, int flags) { |
461 |
|
|
462 |
|
if (p->ssl!=NULL) { |
463 |
|
|
464 |
|
return send_ssl_socket(p->ssl, (void *) msg, len); |
465 |
|
|
466 |
|
} else { |
467 |
|
|
468 |
|
return sock_send(p->socket, msg, len, flags); |
469 |
|
|
470 |
|
} |
471 |
|
|
472 |
|
} |
473 |
|
|
474 |
|
/** |
475 |
|
* Read a message from the socket in non-blocking mode and |
476 |
|
* with failover. Uses SSL if necessary. |
477 |
|
* @param sock A port handler |
478 |
|
* @param buf The buffer to read a message into |
479 |
|
* @param len The length of the buffer |
480 |
|
* @param flags Optional recv flags |
481 |
|
* @return Returns the bytes read or -1 if an error occured |
482 |
|
*/ |
483 |
|
int port_recv(Port_T p, char *buf, int len, int flags) { |
484 |
|
|
485 |
|
if (p->ssl!=NULL) { |
486 |
|
int error; |
487 |
|
error = recv_ssl_socket(p->ssl, buf, len); |
488 |
|
|
489 |
|
return error; |
490 |
|
|
491 |
|
} else { |
492 |
|
|
493 |
|
return sock_recv(p->socket, buf, len, flags); |
494 |
|
|
495 |
|
} |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
/** |
/** |
500 |
* Send the message 'msg' down the socket in non-blocking mode and |
* Send the message 'msg' down the socket in non-blocking mode and |