使用libuv进行客户端开发

使用libuv进行客户端开发,在Linux下测试没有问题,当移植到win7下面就报错了,错误信息如下:
Valid XHTML

使用libuv进行客户端开发_第1张图片

具体代码:

.......
   void uv_write_cb(uv_write_t *req,int status)
    {
        if(status == -1)
        {
            cout<<"error on_write_end"<<endl;
            return;
        }
        //cout<<"write_end!!!"<<endl;
        req->handle->data = req->data;

        uv_read_start(req->handle,alloc_buffer,uv_read_cb);
        //req->handle->loop->stop_flag = 1;
    }

......
    void connect_server(uv_connect_t *req,int status)
    {
            ......
            char buffer[100];
            uv_buf_t buf = uv_buf_init(buffer,sizeof(buffer));

            buf.len = strlen(fileName)+1;
            buf.base = fileName; 
            uv_stream_t* tcp = req->handle;

            uv_write_t write_req;
            write_req.data = req->data;
            int buf_count = 1;
        uv_write(&write_req,tcp,&buf,buf_count,client::uv_write_cb);
            ......
    }






    int _tmain(int argc, _TCHAR* argv[])
    {
       ......
       _loop = uv_default_loop();
       uv_tcp_t socket;
       uv_tcp_init(_loop,&socket);
       uv_connect_t connect;
       connect.data = (void*)this;
       //struct sockaddr dest;
       struct sockaddr_in dest;
       uv_ip4_addr(_ipaddr.c_str(),_port,&dest);
       //struct sockaddr addrInfo;

       uv_tcp_connect(&connect,&socket,(const struct sockaddr*)&dest,connect_server);

       uv_run(_loop,UV_RUN_DEFAULT);
       return 0;
       ......
    }

你可能感兴趣的:(使用libuv进行客户端开发)