Показать сообщение отдельно
Старый 07.06.2007, 15:44   #2  
Armoshka is offline
Armoshka
Участник
 
6 / 10 (1) +
Регистрация: 31.03.2007
Адрес: Астана
Нашел в каком направлении искать.
В Axapte 4 отсуствует tutorial_TicTacToy (крестики нолики)

X++:
static void CreateConnection(Args _args)
{
    #Socks
    Dll               dll;
    DllFunction       dllConnect;
    DllFunction       dllSocket;
    DllFunction       dllPort;
    DllFunction       dllHost;
    anytype           socketValue;
    anytype           retVal;
    int               host;
    anytype           port;
    InteropPermission perm;
    int               intPort,socket ;
    ;
    perm = new InteropPermission(InteropKind::DllInterop);
    perm.assert();

    dll = new Dll("Ws2_32.dll");
       CodeAccessPermission::revertAssert();
    if (dll != null)
    {
        perm = new InteropPermission(InteropKind::DllInterop);
    // Grants permission to execute the DLLFunction.new method.
    // DLLFunction.new runs under code access security.
        perm.assert();

        dllConnect = new DllFunction(dll, "connect");
        dllSocket = new DllFunction(dll,"socket");
        dllPort = new DllFunction(dll,"htons");
        dllHost = new DllFunction(dll,"inet_addr");

        dllSocket.arg(ExtTypes::DWord,ExtTypes::DWord,ExtTypes::DWord);
        dllSocket.returns(ExtTypes::DWord);

        socket = dllSocket.call(#AF_INET,#SOCK_STREAM,#IPPROTO_IP);

        if (dllHost!=null){
           dllHost.arg(ExtTypes::String);
           dllHost.returns(ExtTypes::DWord);
           host = dllHost.call("127.0.0.1");
        }

        if (dllPort!=null){

            dllPort.arg(ExtTypes::Pointer);
            dllPort.returns(ExtTypes::String);
            port = dllPort.call(intPort);
        }

        if (dllConnect != null)
        {
            dllConnect.returns(ExtTypes::DWord);

            retVal = dllConnect.call();
        }
        // Closes the code access permission scope.
       CodeAccessPermission::revertAssert();
    }
Сокет запускается, но проблема в том что для соединения нужно передать Хост и порт. Так это делается С++
X++:
 // The sockaddr_in structure specifies the address family,
  // IP address, and port of the server to be connected to.
  sockaddr_in clientService; 
  clientService.sin_family = AF_INET;
  clientService.sin_addr.s_addr = inet_addr( "127.0.0.1" );
  clientService.sin_port = htons( 27015 );
Вот этот не могу переделать под Axapta