emscripten-core / emscripten-core/emscripten
About the use of tcp_echo_client.c and tcp_echo_server.p
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Hello!
When I run tcp_echo_client.c, I cannot connect to the server run by tcp_echo_server.py. The server can print the connection request, but `emscripten_websocket_get_ready_state` always returns 0, and the connection cannot be established correctly.
Does it mean that as a bridge, it can only connect to the websocket server, but not to TCP? Then why does your sample code have both websocket connection and connect(socket)? If you see this, please help me solve my doubts. Thank you.
I used cmake to compile, here is my CMake
``` cmake
cmake_minimum_required(VERSION 3.6)
project(test_main)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_CXX_STANDARD 11)
if (DEFINED EMSCRIPTEN)
list(APPEND LINK_OPTIONS -sWASM=1 -sPROXY_POSIX_SOCKETS=1 -lwebsocket.js -sUSE_PTHREADS=1)
# list(APPEND LINK_OPTIONS -sWASM=1)
endif ()
set(CMAKE_EXECUTABLE_SUFFIX ".html") # 编译生成.html
add_executable(test_main test_emscripten.cpp)
target_link_options(test_main PUBLIC ${LINK_OPTIONS})
```
Contributor guide
Assessment
This issue has not been assessed yet.