MCPcopy Create free account
hub / github.com/OpenSees/OpenSees / sendMsg

Method sendMsg

SRC/actor/channel/TCP_SocketSSL.cpp:658–699  ·  view source on GitHub ↗

void Send(Message &): Method to send a message to an address given by other_Addr.addr_in.

Source from the content-addressed store, hash-verified

656// void Send(Message &):
657// Method to send a message to an address given by other_Addr.addr_in.
658int
659TCP_SocketSSL::sendMsg(int dbTag, int commitTag,
660 const Message &msg, ChannelAddress *theAddress)
661{
662 // first check address is the only address a TCP_socket can send to
663 SocketAddress *theSocketAddress = 0;
664 if (theAddress != 0) {
665 if (theAddress->getType() == SOCKET_TYPE)
666 theSocketAddress = (SocketAddress *)theAddress;
667 else {
668 opserr << "TCP_SocketSSL::sendMsg() - a TCP_SocketSSL ";
669 opserr << "can only communicate with a TCP_SocketSSL";
670 opserr << " address given is not of type SocketAddress\n";
671 return -1;
672 }
673 if (memcmp((char *) &other_Addr.addr_in, (char *) &theSocketAddress->address.addr_in,
674 theSocketAddress->addrLength) != 0) {
675
676 opserr << "TCP_SocketSSL::sendMsg() - a TCP_SocketSSL ";
677 opserr << "can only communicate with one other TCP_SocketSSL\n";
678 return -1;
679 }
680 }
681
682 // if o.k. get a pointer to the data in the message and
683 // place the incoming data there
684 int nleft;
685 char *gMsg;
686 gMsg = msg.data;
687 nleft = msg.length;
688
689 if (SSL_write(ssl, gMsg, nleft) != nleft) {
690 opserr << "TCP_SocketSSL::sendMsg() - could not write data\n";
691 SSL_shutdown(ssl);
692 SSL_free(ssl);
693 SSL_CTX_free(ctx);
694 cleanup_sockets();
695 return -2;
696 }
697
698 return 0;
699}
700
701
702int

Callers

nothing calls this directly

Calls 2

cleanup_socketsFunction · 0.70
getTypeMethod · 0.45

Tested by

no test coverage detected