Changeset 483


Ignore:
Timestamp:
Nov 29, 2009, 9:20:43 AM (12 years ago)
Author:
rossy
Message:

fixed testclient

Location:
Daodan
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • Daodan/Flatline/build_test.bat

    r457 r483  
    1 gcc -O3 -s -Wall -o testserver src/testserver.c src/Flatline.c src/Flatline_Win32.c -lws2_32
    2 gcc -O3 -s -Wall -o testclient src/testclient.c src/Flatline.c src/Flatline_Win32.c -lws2_32
     1gcc -O3 -s -Wall -o testserver src/testserver.c src/Flatline.c src/Flatline_Net.c src/Flatline_Win32.c -lws2_32
     2gcc -O3 -s -Wall -o testclient src/testclient.c src/Flatline.c src/Flatline_Net.c src/Flatline_Win32.c -lws2_32
  • Daodan/Flatline/src/Flatline.c

    r460 r483  
    1313bool FLrServer_Run()
    1414{
    15         return Net_Listen(27777, FLrListen_PacketCallback);
     15        return NetUDPServer_Listen(27777, FLrServer_PacketCallback);
    1616}
  • Daodan/Flatline/src/Flatline.h

    r460 r483  
    4141typedef struct sockaddr sockaddr;
    4242typedef struct sockaddr_in sockaddr_in;
     43typedef sockaddr_storage sockaddr_in6;
    4344
    4445bool NetUDPServer_Listen(uint16_t port, bool (*packet_callback)(char* data, int datalen, int from));
    45 bool NetUDPServer_Send(sockaddr* address, char* data, int datalen)
     46bool NetUDPServer_Send(sockaddr* address, char* data, int datalen);
    4647
    4748int NetUDPSocket_Create(uint16_t port);
    48 bool NetUDPSocket_Send(int socket, int ip, uint16_t port, char* data, int datalen);
     49bool NetUDPSocket_Send(int socket, const sockaddr* address, const char* data, int datalen);
    4950void NetUDPSocket_Close(int sock);
    5051
     
    6667
    6768
    68 bool FLrListen_PacketCallback(char* data, int datalen, int from);
    69 bool FLrListen_Run();
     69bool FLrServer_PacketCallback(char* data, int datalen, int from);
     70bool FLrServer_Run();
  • Daodan/Flatline/src/Flatline_Net.c

    r460 r483  
    8484}
    8585
    86 bool NetUDPSocket_Send(int socket, sockaddr* address, char* data, int datalen)
     86bool NetUDPSocket_Send(int socket, const sockaddr* address, const char* data, int datalen)
    8787{
    88         uint32_t addr_size;
     88        int addr_size;
    8989        switch (address->sa_family)
    9090        {
     
    9595                        addr_size = sizeof(sockaddr_in6);
    9696                        break;
     97                default:
     98                        addr_size = sizeof(sockaddr_storage);
    9799        }
    98100        return sendto(socket, data, datalen, 0, address, addr_size);
     
    101103bool NetUDPSocket_Recieve(int socket, sockaddr_storage* address, char* data, uint16_t* datalen)
    102104{
    103         uint32_t msg_size = recvfrom(socket, data, 512, 0, address, sizeof(sockaddr_storage));
     105        int address_size = sizeof(sockaddr_storage);
     106        uint32_t msg_size = recvfrom(socket, data, 512, 0, (sockaddr*)address, &address_size);
    104107        if (msg_size == 0)
    105108                return false;
  • Daodan/Flatline/src/testclient.c

    r457 r483  
    55{
    66        NetPlatform_Initalize();
    7         int sock = Net_CreateSocket(0);
     7        int sock = NetUDPSocket_Create(0);
    88        puts("Sending 100 two byte packets . . .");
     9       
     10        sockaddr_in address = { .sin_family = AF_INET, .sin_port = htons(27777), .sin_addr.S_un.S_addr = inet_addr("192.168.0.100") };
    911       
    1012        int i;
    1113        for (i = 0; i < 100; i ++)
    1214        {
    13                 if (Net_Send(sock, inet_addr("127.0.0.1"), 27777, "hi", 3))
     15                if (NetUDPSocket_Send(sock, (sockaddr*)&address, "hi", 2))
    1416                        putchar('*');
    1517                else
    1618                        putchar('x');
    1719        }
    18         Net_CloseSocket(sock);
     20        NetUDPSocket_Close(sock);
    1921        NetPlatform_Shutdown();
    2022        return 0;
  • Daodan/Flatline/src/testserver.c

    r457 r483  
    44{
    55        NetPlatform_Initalize();
    6         FLrListen_Run();
     6        FLrServer_Run();
    77        NetPlatform_Shutdown();
    88        return 0;
  • Daodan/src/Daodan_Win32.c

    r476 r483  
    3636        Rect.bottom = Rect.top + Height;
    3737        AdjustWindowRect(&Rect, WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_TILEDWINDOW , FALSE);
    38 
    39         PlatformData->Window = CreateWindowEx(0, "ONI ", "ONI ", WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_TILEDWINDOW , Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, NULL, NULL, PlatformData->Instance, NULL);
     38        PlatformData->Window = CreateWindowEx(0, "ONI ", "ONI ", WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_OVERLAPPED, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, NULL, NULL, PlatformData->Instance, NULL);
     39       
    4040        ShowWindow(PlatformData->Window, SW_SHOWNORMAL);
    4141        UpdateWindow(PlatformData->Window);
Note: See TracChangeset for help on using the changeset viewer.