|
53 | 53 | * connect to these hosts over the Internet. |
54 | 54 | * |
55 | 55 | * Something that initiates a connection to a remote system is called a |
56 | | - * "client," connecting to a "server." To establish a connection, use |
57 | | - * the NET_Address you resolved with NET_CreateClient(). Once the connection |
58 | | - * is established (a non-blocking operation), you'll have a NET_StreamSocket |
| 56 | + * "client," connecting to a "server." To establish a connection, use the |
| 57 | + * NET_Address you resolved with NET_CreateClient(). Once the connection is |
| 58 | + * established (a non-blocking operation), you'll have a NET_StreamSocket |
59 | 59 | * object that can send and receive data over the connection, using |
60 | 60 | * NET_WriteToStreamSocket() and NET_ReadFromStreamSocket(). |
61 | 61 | * |
62 | | - * To instead be a server, that clients connect to, call |
63 | | - * NET_CreateServer() to get a NET_Server object. All a NET_Server does is |
64 | | - * allow you to accept connections from clients, turning them into |
65 | | - * NET_StreamSockets, where you can read and write from the opposite side of |
66 | | - * the connection from a given client. |
| 62 | + * To instead be a server, that clients connect to, call NET_CreateServer() to |
| 63 | + * get a NET_Server object. All a NET_Server does is allow you to accept |
| 64 | + * connections from clients, turning them into NET_StreamSockets, where you |
| 65 | + * can read and write from the opposite side of the connection from a given |
| 66 | + * client. |
67 | 67 | * |
68 | 68 | * These things are, underneath this API, TCP connections, which means you can |
69 | 69 | * use a client or server to talk to something that _isn't_ using SDL_net at |
|
73 | 73 | * There are tradeoffs to using these, especially in poor network conditions. |
74 | 74 | * Another option is to use "datagram sockets," which map to UDP packet |
75 | 75 | * transmission. With datagrams, everyone involved can send small packets of |
76 | | - * data that may arrive in any order, or not at all, but transmission |
77 | | - * can carry on if a packet is lost, each packet is clearly separated |
78 | | - * from every other, and communication can happen in a peer-to-peer model |
79 | | - * instead of client-server: while datagrams can be more complex, these _are_ |
80 | | - * useful properties not avaiable to stream sockets. |
81 | | - * NET_CreateDatagramSocket() is used to prepare for datagram communication, |
82 | | - * then NET_SendDatagram() and NET_ReceiveDatagram() transmit packets. |
| 76 | + * data that may arrive in any order, or not at all, but transmission can |
| 77 | + * carry on if a packet is lost, each packet is clearly separated from every |
| 78 | + * other, and communication can happen in a peer-to-peer model instead of |
| 79 | + * client-server: while datagrams can be more complex, these _are_ useful |
| 80 | + * properties not avaiable to stream sockets. NET_CreateDatagramSocket() is |
| 81 | + * used to prepare for datagram communication, then NET_SendDatagram() and |
| 82 | + * NET_ReceiveDatagram() transmit packets. |
83 | 83 | * |
84 | 84 | * As previously mentioned, SDL_net's API is "non-blocking" (asynchronous). |
85 | 85 | * Any network operation might take time, but SDL_net's APIs will not wait |
86 | | - * until they complete. Any operation will return immediately, with options |
87 | | - * to check if the operation has completed later. Generally this is what |
88 | | - * a video game needs, but there are times where it makes sense to pause |
89 | | - * until an operation completes; in a background thread this might make |
90 | | - * sense, as it could simplify the code dramatically. |
| 86 | + * until they complete. Any operation will return immediately, with options to |
| 87 | + * check if the operation has completed later. Generally this is what a video |
| 88 | + * game needs, but there are times where it makes sense to pause until an |
| 89 | + * operation completes; in a background thread this might make sense, as it |
| 90 | + * could simplify the code dramatically. |
91 | 91 | * |
92 | 92 | * The functions that block until an operation completes: |
93 | 93 | * |
|
0 commit comments