It should be noted that bnet_recv() is a blocking read. 1: on hard end of file (i.e. network connection close) (-2) if maxbytes is less than the record size sent. Large enough, bnet_recv() realloc() the buffer. Read into sock->msg and is sock->msglen bytes. Length that follows as four bytes in network byte order. Int bnet_recv(BSOCK *sock) This routine is similar to a read() except To read a packet, one uses the subroutine: It will return non-zero if thereĪre errors or the line is closed (no more transmissions should be sent). The is_bnet_stop(BSOCK *bsock) function will return 0 if there noĮrrors and you can continue sending. *bsock) which will return 0 if there is no error or non-zero if there The return status is theįro additional error information, you can call is_bnet_error(BSOCK Int bnet_fsend(BSOCK *sock, char *format, …) and it allows you to sendĪ formatted messages somewhat like fprintf(). In the case of a failure, an error message will be sent to the JCRĬontained within the bsock packet. Returns 0 on failure Returns 1 on success To send a packet,īnet_send() first writes four bytes in network byte order than indicate The data to be sent isĮxpected to be in sock->msg and be sock->msglen bytes. Int bnet_send(BSOCK *sock) This routine is equivalent to a write()Įxcept that it handles the low level details. To send a packet, one uses the subroutine: Any error message will generally be sent to Return, it means that a fatal error occurred and that you should not If not successful, bnet_open() returns a NULL. Pointer to be used in subsequent bnet_send() and bnet_read() requests. *fatal) bnet_open(), if successful, returns the Bareos sock descriptor To establish a connection to a server, use the subroutine:īSOCK *bnet_open(void *jcr, char *host, char *service, int port, int Would not be appropriate to put locks inside the bnet subroutines for Then you must implement some locking mechanism. If you envision having two threads using the same BSOCK, think twice, The wait in the Storageĭaemon is done in one thread and then passed to another thread for Opened and it is waiting for a job to start. The exception to this rule is when the socket is first It is highly recommended that only a single thread access anyīSOCK packet. However, theyĪssume that there is only one reader or writer on the socket at any These bnet routines work fine in a threaded environment. Transferred are considered to be binary data. Of how many low level write() and read() calls are needed. Socket will be received as a single record on the other end regardless Using the routines described below (bnet_open, bnet_write, bnet_recv,Īnd bnet_close) guarantees that the number of bytes you write into the The chapter Network Sequence Diagrams contains message sequences of backup, restore and copy jobs as examples, respectively. Pipes are not used as they are considered unreliable for large serial Transfers are done with read() and write() requests on system sockets. Src/lib/bnet.c and src/lib/bnet_server.c.īareos’s network protocol is basically a “packet oriented” protocolīuilt on a standard TCP/IP streams. The definitiveĭefinition of the protocol can be found in src/lib/bsock.h, This document describes the TCP/IP protocol used by Bareos toĬommunicate between the various daemons and services. Warning: This document is for the development version of Bareos Documentation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |