#include <stdlib.h>
#include <string.h>
#include <errno.h>
-#include <pthread.h>
#include <signal.h>
-#include <sys/time.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <freerdp/constants.h>
+#include <freerdp/utils/tcp.h>
#include <freerdp/server/rdpsnd.h>
#include "sf_audin.h"
#include "sfreerdp.h"
-#define SAMPLE_SERVER_USE_CLIENT_RESOLUTION 0
+#define SAMPLE_SERVER_USE_CLIENT_RESOLUTION 1
#define SAMPLE_SERVER_DEFAULT_WIDTH 1024
#define SAMPLE_SERVER_DEFAULT_HEIGHT 768
}
else
{
- client->settings->DesktopWidth = 640;
- client->settings->DesktopHeight = 480;
+ client->settings->DesktopWidth = SAMPLE_SERVER_DEFAULT_WIDTH;
+ client->settings->DesktopHeight = SAMPLE_SERVER_DEFAULT_HEIGHT;
}
+ context->rfx_context->width = client->settings->DesktopWidth;
+ context->rfx_context->height = client->settings->DesktopHeight;
update->DesktopResize(update->context);
context->activated = FALSE;
}
printf("Failed to get FreeRDP file descriptor\n");
break;
}
+
+#ifndef _WIN32
+ /* winsock's select() only works with sockets ! */
WTSVirtualChannelManagerGetFileDescriptor(context->vcm, rfds, &rcount);
+#endif
max_fds = 0;
FD_ZERO(&rfds_set);
if (select(max_fds + 1, &rfds_set, NULL, NULL, NULL) == -1)
{
+#ifdef _WIN32
+ /* error codes set by windows sockets are not made available through errno ! */
+ int wsa_error = WSAGetLastError();
+ if (!((wsa_error == WSAEWOULDBLOCK) ||
+ (wsa_error == WSAEINPROGRESS) ||
+ (wsa_error == WSAEINTR)))
+ {
+ printf("select failed (WSAGetLastError: %d)\n", wsa_error);
+ break;
+ }
+#else
/* these are not really errors */
if (!((errno == EAGAIN) ||
(errno == EWOULDBLOCK) ||
(errno == EINPROGRESS) ||
(errno == EINTR))) /* signal occurred */
{
- printf("select failed\n");
+ printf("select failed (errno: %d)\n", errno);
break;
}
+#endif
}
if (client->CheckFileDescriptor(client) != TRUE)
static void test_peer_accepted(freerdp_listener* instance, freerdp_peer* client)
{
- pthread_t th;
-
- pthread_create(&th, 0, test_peer_mainloop, client);
- pthread_detach(th);
+ HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) test_peer_mainloop, (void*) client, 0, NULL);
+ if (hThread != NULL) {
+ CloseHandle(hThread);
+ }
}
static void test_server_mainloop(freerdp_listener* instance)
{
freerdp_listener* instance;
- /* Ignore SIGPIPE, otherwise an SSL_write failure could crash your server */
- signal(SIGPIPE, SIG_IGN);
-
instance = freerdp_listener_new();
instance->PeerAccepted = test_peer_accepted;
test_dump_rfx_realtime = FALSE;
/* Open the server socket and start listening. */
+ freerdp_wsa_startup();
if (instance->Open(instance, NULL, 3389) &&
instance->OpenLocal(instance, "/tmp/tfreerdp-server.0"))
{
/* Entering the server main loop. In a real server the listener can be run in its own thread. */
test_server_mainloop(instance);
}
+ freerdp_wsa_cleanup();
freerdp_listener_free(instance);