1 / 4

TCP/IP Protocol

TCP/IP Protocol. Send stream of bytes. Each stream is a message which has msgid, msgLen, and the content. msgid and msgLen are unsigned short variables. msgLen tells the recipient the number of bytes to receive if string of variable length is involved. Definition of msgid:

hisa
Download Presentation

TCP/IP Protocol

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TCP/IP Protocol • Send stream of bytes. • Each stream is a message which has msgid, msgLen, and the content. • msgid and msgLen are unsigned short variables. • msgLen tells the recipient the number of bytes to receive if string of variable length is involved.

  2. Definition of msgid: #define CPAMID(c) ((((UInt16)c) << 8) + (UInt16)c) #define kInvoke CPAMID('i’) #define kInvokeRpy CPAMID('I') Example of msg structs: typedef struct InvokeMsg { MSG_HEADER;char clientID[CLIENT_ID_LEN] ;char methodName[METHOD_NAME_LEN]; char parameterList[1]; } InvokeMsg ; No pointers should be transferred. Every character should be contiguous. Initial idea: ChaimsAttrValList implemented as strings delimited by null character: string1\0string2\0. TCP/IP Interface

  3. Sample Compiled Client Code ChaimsCallID Client::INVOKE (ChaimsClientID clientID, char* methodName, ChaimsAttrValList * attrvalseq) { /* create a struct to send */ struct InvokeMsg* msgToSend = new InvokeMsg; msgToSend->msgid = kInvoke; msgToSend->msgLen = INVOKE_MSG_PREFIX_LEN + attrvalseq->getLength(); strcpy(msgToSend->clientID, clientID); strcpy(msgToSend->methodName, methodName); memcpy(msgToSend->parameterList, attrvalseq->getValue(), TCPComm->send((char*)msgToSend, (int)msgToSend->msgLen); delete msgToSend; /* receive a struct */ struct InvokeRpy *rpy =TCPComm->receive(rpy, sizeof(rpy)); ChaimsCallID ret = rpy->callID; return ret; }

  4. C++/Java Server/Client • Implementation language should be transparent. • Byte streams are received via TCP/IP. • Network order: • Integral values in Java are in network order, so functions like htonl should be used to convert data before send from C++.

More Related