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

Method recvMsg

SRC/actor/channel/TCP_SocketSSL.cpp:547–593  ·  view source on GitHub ↗

void Recv(Message &): Method to receive a message, also sets other_Addr.addr_in to that of sender

Source from the content-addressed store, hash-verified

545// void Recv(Message &):
546// Method to receive a message, also sets other_Addr.addr_in to that of sender
547int
548TCP_SocketSSL::recvMsg(int dbTag, int commitTag,
549 Message &msg, ChannelAddress *theAddress)
550{
551 // first check address is the only address a TCP_socket can send to
552 SocketAddress *theSocketAddress = 0;
553 if (theAddress != 0) {
554 if (theAddress->getType() == SOCKET_TYPE)
555 theSocketAddress = (SocketAddress *)theAddress;
556 else {
557 opserr << "TCP_SocketSSL::recvMsg() - a TCP_SocketSSL ";
558 opserr << "can only communicate with a TCP_SocketSSL";
559 opserr << " address given is not of type SocketAddress\n";
560 return -1;
561 }
562 if (memcmp((char *) &other_Addr.addr_in, (char *) &theSocketAddress->address.addr_in,
563 theSocketAddress->addrLength) != 0) {
564
565 opserr << "TCP_SocketSSL::recvMsg() - a TCP_SocketSSL ";
566 opserr << "can only communicate with one other TCP_SocketSSL\n";
567 return -1;
568 }
569 }
570
571 // if o.k. get a pointer to the data in the message and
572 // place the incoming data there
573 int nleft, nread;
574 char *gMsg;
575 gMsg = msg.data;
576 nleft = msg.length;
577
578 while (nleft > 0) {
579 nread = SSL_read(ssl, gMsg, nleft);
580 if (nread < 0) {
581 opserr << "TCP_SocketSSL::recvMsg() - could not read data\n";
582 SSL_shutdown(ssl);
583 SSL_free(ssl);
584 SSL_CTX_free(ctx);
585 cleanup_sockets();
586 return -2;
587 }
588 nleft -= nread;
589 gMsg += nread;
590 }
591
592 return 0;
593}
594
595
596// void Recv(Message &):

Callers

nothing calls this directly

Calls 2

cleanup_socketsFunction · 0.70
getTypeMethod · 0.45

Tested by

no test coverage detected