Commit dce97146 authored by GUYOT DOMINIQUE's avatar GUYOT DOMINIQUE
Browse files

Remove all C casts from client and server.

parent f50d7b4c
......@@ -85,7 +85,8 @@ PL
assert(r == 0);
//r = uv_tcp_connect(con, tcp, (const struct sockaddr*)&dest, con_cb);
r = uv_tcp_connect(con, tcp, (const struct sockaddr*)&dest,
//r = uv_tcp_connect(con, tcp, (const struct sockaddr*)&dest,
r = uv_tcp_connect(con, tcp, reinterpret_cast<const struct sockaddr*>(&dest),
[](uv_connect_t* c, int status){
PL
Client* C = static_cast<Client*>(c->handle->data);
......@@ -168,7 +169,8 @@ PL
int r;
r = uv_read_start(stream,
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->header;},
//[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->header;},
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = (static_cast<Client*>(handle->data))->header;},
[](uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf){
PL
Client* C = static_cast<Client*>(stream->data);
......@@ -196,7 +198,8 @@ PL
cmd.base = static_cast<char*>(malloc(size()));
r = uv_read_start(stream,
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->cmd;},
//[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->cmd;},
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = (static_cast<Client*>(handle->data))->cmd;},
[](uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf){
PL
Client* C = static_cast<Client*>(stream->data);
......@@ -225,7 +228,8 @@ PL
int r;
r = uv_read_start(stream,
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->header;},
//[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->header;},
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = (static_cast<Client*>(handle->data))->header;},
[](uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf){
PL
Client* C = static_cast<Client*>(stream->data);
......@@ -252,7 +256,8 @@ PL
data.base = static_cast<char*>(malloc(size()));
r = uv_read_start(stream,
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->data;},
//[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = ((Client*)(handle->data))->data;},
[](uv_handle_t* handle, size_t size, uv_buf_t* buf){*buf = (static_cast<Client*>(handle->data))->data;},
[](uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf){
PL
Client* C = static_cast<Client*>(stream->data);
......@@ -342,7 +347,7 @@ PL
uv_loop_t* loop = uv_default_loop();
Client* C = new Client(loop);
C->connect("134.214.33.18:8000");
C->connect("127.0.0.1:8000");
r = uv_run(loop, UV_RUN_DEFAULT);
assert(r == 0);
......
......@@ -64,7 +64,7 @@ PL
uv_tcp_nodelay(tcp,1);
stream = reinterpret_cast<uv_stream_t*>(tcp);
r = uv_accept(server, stream);
assert(r == 0);
......@@ -96,8 +96,8 @@ PL
[](uv_handle_t* tcp, size_t size, uv_buf_t* buf){*buf = (static_cast<Service*>(tcp->data))->header;},
[](uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf){
PL
Service* S = reinterpret_cast<Service*>(stream->data);
Service* S = static_cast<Service*>(stream->data);
//is read complete?
if (nread == (ssize_t)buf->len){
uv_read_stop(stream);
......@@ -144,7 +144,8 @@ PL
r = uv_write(&wr, stream, &header, 1,
[](uv_write_t* wr, int status){
PL
Service* S = reinterpret_cast<Service*>(wr->handle->data);
Service* S = static_cast<Service*>(wr->handle->data);
S->send_cmd();
PL
}
......@@ -163,7 +164,7 @@ PL
r = uv_write(&wr, stream, &cmd, 1,
[](uv_write_t* wr, int status){
PL
Service* S = reinterpret_cast<Service*>(wr->handle->data);
Service* S = static_cast<Service*>(wr->handle->data);
S->recv_header();
PL
}
......@@ -180,7 +181,7 @@ PL
r = uv_write(&wr, stream, &header, 1,
[](uv_write_t* wr, int status){
PL
Service* S = reinterpret_cast<Service*>(wr->handle->data);
Service* S = static_cast<Service*>(wr->handle->data);
S->send_data();
PL
}
......@@ -198,7 +199,7 @@ PL
r = uv_write(&wr, stream, &sdata, 1,
[](uv_write_t* wr, int status){
PL
Service* S = reinterpret_cast<Service*>(wr->handle->data);
Service* S = static_cast<Service*>(wr->handle->data);
S->recv_header();
PL
}
......@@ -219,7 +220,7 @@ PL
[](uv_handle_t* tcp, size_t size, uv_buf_t* buf){*buf = (static_cast<Service*>(tcp->data))->rdata;},
[](uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf){
PL
Service* S = reinterpret_cast<Service*>(stream->data);
Service* S = static_cast<Service*>(stream->data);
//is read complete?
if (nread == (ssize_t)buf->len){
......@@ -259,7 +260,7 @@ PL
uv_close(handle,
[](uv_handle_t* handle){
PL
Service* S = reinterpret_cast<Service*>(handle->data);
Service* S = static_cast<Service*>(handle->data);
delete(S);
PL
}
......@@ -326,7 +327,8 @@ PL
r = uv_ip4_addr(ip.c_str(), port, &saddr);
assert(r == 0);
r = uv_tcp_bind(server, (const struct sockaddr*)&saddr, 0);
//r = uv_tcp_bind(server, (const struct sockaddr*)&saddr, 0);
r = uv_tcp_bind(server, reinterpret_cast<const struct sockaddr*>(&saddr), 0);
assert(r == 0);
PL
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment