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

Method sendVector

SRC/actor/channel/TCP_SocketSSL.cpp:877–932  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

875// void Send(Vector &):
876// Method to send a Vector to an address given by other_Addr.addr_in.
877int
878TCP_SocketSSL::sendVector(int dbTag, int commitTag,
879 const Vector &theVector, ChannelAddress *theAddress)
880{
881 // first check address is the only address a TCP_socket can send to
882 SocketAddress *theSocketAddress = 0;
883 if (theAddress != 0) {
884 if (theAddress->getType() == SOCKET_TYPE)
885 theSocketAddress = (SocketAddress *)theAddress;
886 else {
887 opserr << "TCP_SocketSSL::sendVector() - a TCP_SocketSSL ";
888 opserr << "can only communicate with a TCP_SocketSSL";
889 opserr << " address given is not of type SocketAddress\n";
890 return -1;
891 }
892 if (memcmp((char *) &other_Addr.addr_in, (char *) &theSocketAddress->address.addr_in,
893 theSocketAddress->addrLength) != 0) {
894
895 opserr << "TCP_SocketSSL::sendVector() - a TCP_SocketSSL ";
896 opserr << "can only communicate with one other TCP_SocketSSL\n";
897 return -1;
898 }
899 }
900
901 // if o.k. get a pointer to the data in the Vector and
902 // place the incoming data there
903 int nleft;
904 double *data = theVector.theData;
905 char *gMsg = (char *)data;
906 nleft = theVector.sz * sizeof(double);
907
908#ifndef _WIN32
909 if (endiannessProblem) {
910 void *array = (void *)data;
911 byte_swap(array, theVector.sz, sizeof(double));
912 }
913#endif
914
915 if (SSL_write(ssl, gMsg, nleft) != nleft) {
916 opserr << "TCP_SocketSSL::sendVector() - could not write data\n";
917 SSL_shutdown(ssl);
918 SSL_free(ssl);
919 SSL_CTX_free(ctx);
920 cleanup_sockets();
921 return -2;
922 }
923
924#ifndef _WIN32
925 if (endiannessProblem) {
926 void *array = (void *)data;
927 byte_swap(array, theVector.sz, sizeof(double));
928 }
929#endif
930
931 return 0;
932}
933
934

Callers

nothing calls this directly

Calls 3

byte_swapFunction · 0.70
cleanup_socketsFunction · 0.70
getTypeMethod · 0.45

Tested by

no test coverage detected