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

Method sendMatrix

SRC/actor/channel/TCP_SocketSSL.cpp:760–816  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

758// void Send(Matrix &):
759// Method to send a Matrix to an address given by other_Addr.addr_in.
760int
761TCP_SocketSSL::sendMatrix(int dbTag, int commitTag,
762 const Matrix &theMatrix, ChannelAddress *theAddress)
763{
764 // first check address is the only address a TCP_socket can send to
765 SocketAddress *theSocketAddress = 0;
766 if (theAddress != 0) {
767 if (theAddress->getType() == SOCKET_TYPE)
768 theSocketAddress = (SocketAddress *)theAddress;
769 else {
770 opserr << "TCP_SocketSSL::sendMatrix() - a TCP_SocketSSL ";
771 opserr << "can only communicate with a TCP_SocketSSL";
772 opserr << " address given is not of type SocketAddress\n";
773 return -1;
774 } SocketAddress *theSocketAddress = 0;
775
776 if (memcmp((char *) &other_Addr.addr_in, (char *) &theSocketAddress->address.addr_in,
777 theSocketAddress->addrLength) != 0) {
778
779 opserr << "TCP_SocketSSL::sendMatrix() - a TCP_SocketSSL ";
780 opserr << "can only communicate with one other TCP_SocketSSL\n";
781 return -1;
782 }
783 }
784
785 // if o.k. get a pointer to the data in the Matrix and
786 // place the incoming data there
787 int nleft;
788 double *data = theMatrix.data;
789 char *gMsg = (char *)data;
790 nleft = theMatrix.dataSize * sizeof(double);
791
792#ifndef _WIN32
793 if (endiannessProblem) {
794 void *array = (void *)data;
795 byte_swap(array, theMatrix.dataSize, sizeof(double));
796 }
797#endif
798
799 if (SSL_write(ssl, gMsg, nleft) != nleft) {
800 opserr << "TCP_SocketSSL::sendMatrix() - could not write data\n";
801 SSL_shutdown(ssl);
802 SSL_free(ssl);
803 SSL_CTX_free(ctx);
804 cleanup_sockets();
805 return -2;
806 }
807
808#ifndef _WIN32
809 if (endiannessProblem) {
810 void *array = (void *)data;
811 byte_swap(array, theMatrix.dataSize, sizeof(double));
812 }
813#endif
814
815 return 0;
816}
817

Callers

nothing calls this directly

Calls 3

byte_swapFunction · 0.70
cleanup_socketsFunction · 0.70
getTypeMethod · 0.45

Tested by

no test coverage detected