1e5c31af7Sopenharmony_ci#ifndef _VKSNETWORK_HPP 2e5c31af7Sopenharmony_ci#define _VKSNETWORK_HPP 3e5c31af7Sopenharmony_ci 4e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 5e5c31af7Sopenharmony_ci * Vulkan CTS Framework 6e5c31af7Sopenharmony_ci * -------------------- 7e5c31af7Sopenharmony_ci * 8e5c31af7Sopenharmony_ci * Copyright (c) 2021 The Khronos Group Inc. 9e5c31af7Sopenharmony_ci * 10e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 11e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 12e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 13e5c31af7Sopenharmony_ci * 14e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 15e5c31af7Sopenharmony_ci * 16e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 17e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 18e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 20e5c31af7Sopenharmony_ci * limitations under the License. 21e5c31af7Sopenharmony_ci * 22e5c31af7Sopenharmony_ci *-------------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "vksCommon.hpp" 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_cinamespace de { class Socket; }; 27e5c31af7Sopenharmony_ci 28e5c31af7Sopenharmony_cinamespace vksc_server 29e5c31af7Sopenharmony_ci{ 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_ciconstexpr auto DefaultPort = 59333; 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ci// Conver string (for example "192.168.0.1:59333") to host and port 34e5c31af7Sopenharmony_civoid StringToAddress (const string& str, string& host, int& port ); 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ci// Scan buffer, looking for a packet and call packetInterpreter, returns true if there is possibitly for another packet 37e5c31af7Sopenharmony_cibool ProccessNetworkData (vector<u8>& buffer, const std::function<void(u32, vector<u8>)>& packetInterpreter ); 38e5c31af7Sopenharmony_ci 39e5c31af7Sopenharmony_ci// Sends whole bufer to socket 40e5c31af7Sopenharmony_civoid Send (de::Socket* socket, const vector<u8>& buffer ); 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_ci// Send whole payload and insert [type, size] header before it 43e5c31af7Sopenharmony_civoid SendPayloadWithHeader (de::Socket* socket, u32 type, const vector<u8>& payload ); 44e5c31af7Sopenharmony_ci 45e5c31af7Sopenharmony_ci// Recv some bytes frome socket and insert it at the back of recvb 46e5c31af7Sopenharmony_civoid RecvSome (de::Socket* socket, vector<u8>& recvb); 47e5c31af7Sopenharmony_ci 48e5c31af7Sopenharmony_ci// Recv single packet from socket (it will block until this function get it) 49e5c31af7Sopenharmony_civector<u8> RecvPacket (de::Socket* socket, vector<u8>& recvb, u32 type ); 50e5c31af7Sopenharmony_ci 51e5c31af7Sopenharmony_ci} 52e5c31af7Sopenharmony_ci 53e5c31af7Sopenharmony_ci#endif // _VKSNETWORK_HPP 54