# SocketServer Class Reference

`#include <SocketServer.hh>`

List of all members.

## Public Member Functions
| SocketServer (SocketTCP *tcp_socket, SocketUDP *udp_socket, int the_port)
| socketServer.
| ~SocketServer ()
| Destructor (frees tuple list).
void | open () throw (RTIinternalError)
void | close (long socket, Handle &federation_referenced, FederateHandle &federate_referenced) throw (RTIinternalError)
void | setReferences (long the_socket, Handle federation_reference, FederateHandle federate_reference, unsigned long the_address, unsigned int the_port) throw (RTIinternalError)
void | checkMessage (long socket, NetworkMessage *message) const throw (SecurityError)
int | addToFDSet (fd_set *select_fdset)
| This method is called when the RTIG wants to initialize its FD_SET before doing a select.
Socket * | getActiveSocket (fd_set *select_fdset) const
Socket * | getSocketLink (Handle the_federation, FederateHandle the_federate, TransportType the_type=RELIABLE) const throw (FederateNotExecutionMember, RTIinternalError)
SocketTuple * | getWithReferences (Handle the_federation, FederateHandle the_federate) const throw (FederateNotExecutionMember)
| getWithReferences.
## Private Member Functions
SocketTuple * | getWithSocket (long socket_descriptor) const throw (RTIinternalError)
| getWithSocket (private).
## Private Attributes
SocketTCP * | ServerSocketTCP
SocketUDP * | ServerSocketUDP

## Detailed Description

Liste dynamique mettant en relation un couple(Federation, Federe) avec une Socket TCP. Sont decritent les classes : SocketTuple (l'element de la liste) SocketServer(la liste au niveau du RTIG) CFederationSocketServer (l'interface de la liste precedente au niveau de la federation et de ses objets, qui contient en plus des fonctionnalites de securite)

Definition at line 63 of file SocketServer.hh.

## Constructor & Destructor Documentation

SocketServer | ( | SocketTCP * | tcp_socket,
|  | SocketUDP * | udp_socket,
|  | int | the_port |
| ) |  |  |

socketServer.

Definition at line 142 of file SocketServer.cc.

References SocketServer::ServerSocketTCP, and SocketServer::ServerSocketUDP.

~SocketServer | ( |  | ) |

Destructor (frees tuple list).

Definition at line 155 of file SocketServer.cc.

## Member Function Documentation

void open | ( |  | ) | throw (RTIinternalError)

Allocate a new SocketTuple by Accepting on the ServerSocket. The SocketTuple references are empty. Throw RTIinternalError in case of a memory allocation problem.

Definition at line 293 of file SocketServer.cc.

References SocketTCP::accept(), and SocketServer::ServerSocketTCP.

Referenced by RTIG::openConnection().

Here is the call graph for this function:

void close | ( | long | socket,
|  | Handle & | federation_referenced,
|  | FederateHandle & | federate_referenced |
| ) |  |  | throw (RTIinternalError)

Close and delete the Socket object whose socket is "Socket", and return the former references associated with this socket in the last two parameters. Those returned references can be used for example to force the Federate out of the Federation. Further call to GetSocket with those references will return a NULL Socket object. Throw RTIinternalError if the socket is not found.

Definition at line 99 of file SocketServer.cc.

References SocketTuple::BestEffortLink, SocketUDP::close(), SocketTCP::close(), certi::fedparser::end(), SocketTuple::Federate, SocketTuple::Federation, and SocketTuple::ReliableLink.

Referenced by RTIG::closeConnection().

Here is the call graph for this function:

void setReferences | ( | long | socket,
|  | Handle | federation_reference,
|  | FederateHandle | federate_reference,
|  | unsigned long | address,
|  | unsigned int | port |
| ) |  |  | throw (RTIinternalError)

Change the FederationHandle and the FederateHandle associated with "socket". Once the references have been set for a Socket, they can't be changed. References can be zeros(but should not). Throw RTIinternalError if the References have already been set, or if the Socket is not found.

Definition at line 323 of file SocketServer.cc.

References SocketUDP::attach(), SocketTuple::BestEffortLink, SocketTuple::Federate, SocketTuple::Federation, SocketServer::getWithSocket(), SocketUDP::returnSocket(), and SocketServer::ServerSocketUDP.

Referenced by RTIG::processJoinFederation().

Here is the call graph for this function:

void checkMessage | ( | long | socket_number,
|  | NetworkMessage * | message |
| ) |  |  | const throw (SecurityError)

Check if 'message' coming from socket link 'Socket' has a valid Federate field, that is, the Federate number linked to the socket is the same as the Federate Number specified in the message. If not, throw SecurityError.

Definition at line 61 of file SocketServer.cc.

References Socket::returnSocket().

Referenced by RTIG::chooseProcessingMethod().

Here is the call graph for this function:

int addToFDSet | ( | fd_set * | select_fdset | ) |

This method is called when the RTIG wants to initialize its FD_SET before doing a select.

It will add all open socket to the set.

Returns:
  the highest file descriptor in the FD_SET

Definition at line 39 of file SocketServer.cc.

References certi::fedparser::end().

Referenced by RTIG::execute().

Here is the call graph for this function:

Socket * getActiveSocket | ( | fd_set * | select_fdset | ) | const

This method return the first socket object who has been declared active in the fd_set. It can be called several times to get all active sockets.

Definition at line 198 of file SocketServer.cc.

References certi::fedparser::end().

Referenced by RTIG::execute().

Here is the call graph for this function:

Socket * getSocketLink | ( | Handle | the_federation,
|  | FederateHandle | the_federate,
|  | TransportType | the_type = `RELIABLE` |
| ) |  |  | const throw (FederateNotExecutionMember, RTIinternalError)

Return the Socket object associated with(theFederation, theFederate). If the couple(Federation, Federate) is not found, a FederateNotExecutionMember exception is thrown.

If the Federate has crashed, it should return a NULL socket object, but this should not happen. In fact, when a Client(Federate) crashes, the RTIG is supposed be remove all references to this federate. That's the reason why a RTIinternalError is thrown in that case.

JYR : sorry but we return NULL (avoid rtig crash) because development needed

Definition at line 223 of file SocketServer.cc.

References SocketTuple::BestEffortLink, SocketServer::getWithReferences(), certi::RELIABLE, and SocketTuple::ReliableLink.

Referenced by SecurityServer::getSocketLink().

Here is the call graph for this function:

SocketTuple * getWithReferences | ( | Handle | the_federation,
|  | FederateHandle | the_federate |
| ) |  |  | const throw (FederateNotExecutionMember)

getWithReferences.

Definition at line 254 of file SocketServer.cc.

References certi::fedparser::end().

Referenced by SocketServer::getSocketLink().

Here is the call graph for this function:

SocketTuple * getWithSocket | ( | long | socket_descriptor | ) | const throw (RTIinternalError)`[private]`

getWithSocket (private).

Definition at line 271 of file SocketServer.cc.

References certi::fedparser::end().

Referenced by SocketServer::setReferences().

Here is the call graph for this function:

## Member Data Documentation

SocketTCP* ServerSocketTCP`[private]`

Definition at line 115 of file SocketServer.hh.

Referenced by SocketServer::open(), and SocketServer::SocketServer().

SocketUDP* ServerSocketUDP`[private]`

Definition at line 116 of file SocketServer.hh.

Referenced by SocketServer::setReferences(), and SocketServer::SocketServer().

The documentation for this class was generated from the following files:

- SocketServer.hh
- SocketServer.cc