Lines Matching refs:socket
31 * @file socket.h
35 * This file provides data transmission capabilities, including creating and removing a socket server,
36 * opening and closing sockets, receiving data, and querying basic socket information. \n
66 * @brief Defines socket callbacks.
68 * When a socket is opened or closed, or there is data to process, the related callback is invoked.
75 * @brief Called when a socket is bind.
77 * This callback is invoked to verify the socket or initialize resources related to the socket.
81 * When a socket is async bind, client side need implement this interface.
83 * @param socket Indicates the unique socket fd.
84 * @param info Indicates the information of peer socket.
88 void (*OnBind)(int32_t socket, PeerSocketInfo info);
91 * @brief Called when a socket is closed.
93 * This callback is invoked to release resources related to the socket.
95 * @param socket Indicates the unique socket fd.
96 * @param reason Indicates the reason for closing the socket.
100 void (*OnShutdown)(int32_t socket, ShutdownReason reason);
107 * @param socket Indicates the unique socket fd.
113 void (*OnBytes)(int32_t socket, const void *data, uint32_t dataLen);
120 * @param socket Indicates the unique socket fd.
126 void (*OnMessage)(int32_t socket, const void *data, uint32_t dataLen);
133 * @param socket Indicates the unique socket fd.
140 void (*OnStream)(int32_t socket, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
147 * @param socket Indicates the unique socket fd.
153 void (*OnFile)(int32_t socket, FileEvent *event);
160 * @param socket Indicates the unique socket fd.
167 void (*OnQos)(int32_t socket, QoSEvent eventId, const QosTV *qos, uint32_t qosCount);
170 * @brief Called when an async bind socket is error.
172 * This callback is notice error for the socket.
174 * When a socket is async bind, client side need implement this interface.
176 * @param socket Indicates the unique socket fd.
177 * @param errCode Indicates the error for the async bind socket.
181 void (*OnError)(int32_t socket, int32_t errCode);
184 * @brief Called when a socket is negotiating.
186 * This callback is invoked to negotiating the socket, this callback be called on the server side.
187 * The server can determine whether to bind the socket based on the negotiation result.
190 * @param socket Indicates the unique socket fd.
191 * @param info Indicates the information of peer socket.
198 bool (*OnNegotiate)(int32_t socket, PeerSocketInfo info);
202 * @brief Creates a socket.
204 * A maximum of 15 socket can be created.
206 * @param info Indicates the description of the socket structure.
209 * @return Returns <b>socket fd</b> if the socket creation is successful;
217 * @brief Listens a socket, which is called by server.
219 * @param socket Indicates the the unique socket fd.
220 * @param qos Indicates the QoS requirements for socket. The value cannot be empty.
222 * @param listener Indicates the pointer to the socket callback.
229 int32_t Listen(int32_t socket, const QosTV qos[], uint32_t qosCount, const ISocketListener *listener);
232 * @brief Binds a socket, which is called by client.
237 * @param socket Indicates the the unique socket fd.
238 * @param qos Indicates the QoS requirements for socket. The value cannot be empty.
240 * @param listener Indicates the pointer to the socket callback.
244 * @return Returns <b>SOFTBUS_OK</b> if the socket is bind;
249 int32_t Bind(int32_t socket, const QosTV qos[], uint32_t qosCount, const ISocketListener *listener);
252 * @brief Async bind a socket, which is called by client.
254 * {@link OnBind} is invoked to return whether the socket is successfully bind.
255 * Data can be transmitted only after the socket is successfully bind.
257 * @param socket Indicates the the unique socket fd.
258 * @param qos Indicates the QoS requirements for socket. The value cannot be empty.
259 * @param listener Indicates the pointer to the socket callback.
263 * @return Returns <b>SOFTBUS_OK</b>) if the socket is in binding status,
268 int32_t BindAsync(int32_t socket, const QosTV qos[], uint32_t qosCount, const ISocketListener *listener);
277 * @param socket Indicates the unique socket fd.
283 * @return Returns <b>SOFTBUS_TRANS_INVALID_SOCKET</b> if <b>socket</b> is invalid.
284 * @return Returns <b>SOFTBUS_TRANS_SOCKET_NO_ENABLE</b> if the socket is not bind.
289 int32_t SendBytes(int32_t socket, const void *data, uint32_t len);
294 * @param socket Indicates the unique socket fd.
300 * @return Returns <b>SOFTBUS_INVALID_SOCKET</b> if <b>socket</b> is invalid.
301 * @return Returns <b>SOFTBUS_TRANS_SOCKET_NO_ENABLE</b> if the socket is not bind.
306 int32_t SendMessage(int32_t socket, const void *data, uint32_t len);
315 * @param socket Indicates the unique socket fd.
321 * @return Returns <b>SOFTBUS_INVALID_SOCKET</b> if <b>socket</b> is invalid.
322 * @return Returns <b>SOFTBUS_TRANS_SOCKET_NO_ENABLE</b> if the socket is not bind.
327 int32_t SendStream(int32_t socket, const StreamData *data, const StreamData *ext, const StreamFrameInfo *param);
336 * @param socket Indicates the unique socket fd.
342 * @return Returns <b>SOFTBUS_INVALID_SOCKET</b> if <b>socket</b> is invalid.
343 * @return Returns <b>SOFTBUS_TRANS_SOCKET</b> if the socket is not bind.
348 int32_t SendFile(int32_t socket, const char *sFileList[], const char *dFileList[], uint32_t fileCnt);
351 * @brief Get socket based on a socket fd.
353 * @param socket Indicates the unique socket fd.
359 void Shutdown(int32_t socket);