Commit Graph
50 Commits
Author SHA1 Message Date
Cameron Gutman 7bf16de8e2 Verify source addresses for STUN responses 2026-11-03 00:49:12 -06:00
ReenigneArcher 40d87314d0 Add NXDK (Xbox) support 2026-06-23 17:58:10 -05:00
Cameron Gutman 7022b337a9 Refactor BSD socket errors for Win32 and add EMSGSIZE 2026-03-28 15:03:38 -05:00
MrCreativ3001 3fa9191330 Use lowercase windows headers for easier cross-compilation 2026-02-20 19:33:13 -06:00
Cameron Gutman 07c32c80f9 Use a valid port when calling connect() for local address detection
BSDs (including Darwin) don't like using port 0.
2026-02-06 22:53:54 -06:00
7mile 305993b013 fix: use UDP connect to probe local address (#121) 2026-01-29 18:52:06 -06:00
34074c9ec0 Fixes for Moonlight compatibility on the PS Vita. (#110)
* Use pthread for vita thread managment

* Add thread name to pthread and remove ipv6 from vita

* Fix inclusion of pthread.h so that it is only included on specific platforms (__vita__)

* Fix memory release in ThreadProc for psvita platform

---------

Co-authored-by: MetalfaceScout <logan.mathis@utahtech.edu>
Co-authored-by: Logan Mathis <33127568+MetalfaceScout@users.noreply.github.com>
2025-07-05 18:57:33 -05:00
Cameron Gutman c245fe599d Use higher packet size for remote streaming over end-to-end IPv6 connection
The IPv6 spec guarantees a minimum of 1280 byte MTUs
2024-05-29 13:57:50 -04:00
Cameron Gutman c0e3dc64a4 Add basic QoS attributes to our A/V sockets 2024-02-01 00:15:47 -06:00
zoey jodon c104a97fa0 Add platform support for the 3DS
Prevent wildcard port binding on the 3DS
Add 3DS threading logic
Add 3DS socket logic
Bump the connection timeout to 60s for the 3DS
2024-01-18 18:30:20 -06:00
Cameron Gutman bbf15af837 Revert "Use connected datagram sockets for audio and video"
This causes problems on multi-homed GFE and Sunshine (prior to v0.21) hosts
because audio and video data can be sent back from an address different than
the one we used as our original destination address.

This reverts commit c13f4a323f.
2023-10-26 01:15:27 -05:00
Cameron Gutman 05c3f9c754 Bind our UDP sockets to the same local address used by RTSP handshake
This means we can ensure a consistent local address for our outgoing PING
traffic to keep the UDP flows alive without having to call connect() which breaks
with multi-homed hosts on GFE and Sunshine v0.20 and earlier.
2023-10-26 01:09:26 -05:00
Cameron Gutman 8b84d17c8d Replace additional unsafe string functions 2023-10-06 17:33:37 -05:00
Cameron Gutman c13f4a323f Use connected datagram sockets for audio and video
This ensures unwanted data from other sources is dropped and that our own source address doesn't change while streaming.
2023-09-12 23:29:05 -05:00
Cameron Gutman d3cb8131d1 Revert "Send TCP FIN after completion of our RTSP request"
Existing servers already know how to parse our messages without this,
so we just risk breaking things with middleboxes that don't do half-closed
connections properly. We'll handle this better with encrypted RTSP.

This reverts commit 95e3e26d12.
2023-02-20 16:58:21 -06:00
Cameron Gutman 95e3e26d12 Send TCP FIN after completion of our RTSP request
This allows servers to read until a FIN, just like we do on the client.
2023-02-13 21:47:22 -06:00
Sunguk Lee 4a4a23c7c4 vita: Replace select to poll
now newlib support [this][1]

[1]: https://github.com/vitasdk/newlib/pull/70
2022-01-24 22:16:59 -06:00
Mariotaku 5ed9a6508a Fixed build issue with MinGW (#64) 2021-09-16 01:30:47 -05:00
Cameron Gutman c00f4e15ae Use poll() instead of SO_RCVTIMEO for RTSP timeout support
poll() is more portable than SO_RCVTIMEO
2021-07-01 22:10:46 -05:00
Cameron Gutman da68e64d9b Fix various MSVC warnings 2021-04-29 17:21:12 -05:00
Cameron Gutman 7549243f40 Add the correct definition for ECONNREFUSED for Windows 2021-04-28 17:30:00 -05:00
Cameron Gutman 9c92c12fea Prevent errno.h from including incompatible error codes with Winsock codes 2021-04-28 17:29:33 -05:00
Cameron Gutman c1befbe2a8 Improve audio resync logic to use initial receive time rather send time 2021-04-26 22:43:49 -05:00
Cameron Gutman 3adacb876d Fix incorrect checks for AF_INET6 2021-04-19 23:01:17 -05:00
Cameron Gutman 3979dbd082 Allow compilation on OSes without IPv6 support 2021-04-17 23:40:36 -05:00
Cameron Gutman 4b4162c1a1 Fix redefinition warning for errno.h constants on Windows 2020-11-30 20:44:46 -06:00
Cameron Gutman 5f9f7ce407 Code cleanup: use stdbool.h 2020-11-30 20:38:13 -06:00
Sunguk Lee 6195007bf3 Add missing poll header parts of the VITA 2020-10-23 11:29:02 +09:00
Cameron Gutman 128c1503f2 Don't perform the connection test in resolveHostName() for single addresses unless required 2020-09-06 17:11:14 -07:00
Cameron Gutman 9064d4931f Add createSocket() helper to reduce code duplication 2020-08-29 18:54:11 -07:00
Cameron Gutman 5ddd53e17f Enable media streaming mode for 802.11 WLAN interfaces on Windows 2020-08-11 22:12:58 -07:00
Cameron Gutman 6351749039 Fix TCP connection tests on Linux and BSD 2020-07-26 20:56:39 -07:00
Cameron Gutman 117a7c637f Switch to poll() to be safe against stack corruption from exceeding FD_SETSIZE
Fortunately, the fd_set definition is not prone to stack corruption on Windows,
because FD_SETSIZE is the maximum number of sockets in a fd_set, not
the maximum value socket file descriptor that can be stored in a fd_set.

https://beesbuzz.biz/code/5739-The-problem-with-select-vs-poll
2020-07-26 20:27:58 -07:00
Cameron Gutman 52f489bc46 Fix RTSP handshake errors on networks with broken PMTUD 2019-11-30 21:19:56 -06:00
Cameron Gutman 25528671d2 Fix error value on control stream and RTSP handshake failure 2019-11-02 21:28:05 -07:00
Cameron Gutman 197594f38c Add platform helper function to set socket non-blocking mode 2019-11-02 19:16:46 -07:00
Sunguk Lee 31a1384379 vita: Apply newlib changes
no more need to define `TCP_NODELAY` and `sockaddr_in6` parts
2019-10-05 04:43:28 +09:00
Sunguk Lee 9972440607 vita: Reduce vita custom defines 2019-08-14 01:25:08 +09:00
Cameron Gutman 6eb17a8e73 Fix build warnings 2019-02-26 23:44:10 -08:00
Sunguk Lee d971e3bacc Revert "vita: Redefine network error codes"
This reverts commit 93707b42e9.
2019-02-17 23:58:33 +09:00
Cameron Gutman 639ff18dbb Allow automatic detection of remote streaming 2018-11-21 20:52:50 -08:00
Cameron Gutman 396b02a94d Test each address returned in the getaddrinfo() call and stop blindly preferring IPv4
Fixes NAT64 on iOS 12 and probably other obscure configurations
2018-11-16 00:37:38 -08:00
Cameron Gutman 9396f6c528 Move resolveHostName() into PlatformSockets.c 2018-10-26 17:02:45 -07:00
Cameron Gutman feb46b978e Handle EINTR to fix streaming with GDB attached 2018-08-10 15:51:17 -07:00
Cameron Gutman 219d87486e Check for both EWOULDBLOCK and EAGAIN for OSes where those values differ 2018-07-21 16:12:38 -07:00
Sunguk Lee 93707b42e9 vita: Redefine network error codes
temporary patch until merge vitasdk/newlib#38
2018-07-22 06:01:46 +09:00
Sunguk Lee 53352c1a8e vita: No more need redefine INADDR_ANY 2018-07-22 05:54:32 +09:00
Cameron Gutman 6e7965f013 Use SO_RCVTIMEO to avoid the overhead of an extra syscall per packet 2018-07-16 00:46:40 -07:00
Sunguk Lee ba27e97698 Add vita environment (#22)
* vita: initial port

* vita: implement events, enable input thread

* vita: gethostbyname

* vita: Enable audio

* vita: Fix thread crash on discoonect process

* vita: Handle cannot create thread

* vita: now use newlib's socket apis

* vita: Refactoring for moonlight-stream/moonlight-common-c

* Fix review things

https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2436093

- vita may not support IPv6; so add LC_ASSERT them.
- define inet_ntop to sceNetInetNtop
- guard about failure of sceKernelCreateMutex or sceKernelCreateCond
- remove meanless macros

https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2444677

- !*mutex to *mutex
- remove useless LC_ASSERT then change to use inet_ntop
  in vita system not defined `sockaddr_in6`, so just use `sockaddr_in` instead this.

https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2445642

- define sin6_addr
2016-10-05 16:43:33 -07:00
Cameron Gutman 48a5d63045 Reorganize the folder structure and delete the Xcode build files 2016-03-31 07:22:03 -04:00