int
main()
#include
using namespace std;
#include
#pragma comment(lib, "ws2_32.lib")
intmain()
if(lobyte
(wsadata.wversion)!=2
||hibyte
(wsadata.wversion)!=2
)else
printf
("the winsock 2.2 dll was found okay\n");
// 2.建立監聽套接字
socket listen_socket =::
socket
(af_inet, sock_stream , ipproto_tcp);if
(listen_socket == invalid_socket)
// 3.將監聽套接字與本機進行繫結
sockaddr_in addr_server;
addr_server.sin_family = af_inet;
addr_server.sin_addr.s_un.s_addr = inaddr_any;
// 連線本地任意網絡卡
addr_server.sin_port =
htons
(4567);
if(::
bind
(listen_socket,
(const sockaddr*
)&addr_server,
sizeof
(sockaddr_in)
)== socket_error)
// 4.監聽if(
::listen
(listen_socket,64)
== socket_error)
// 5.監聽成功進行連線
cout <<
"開始監聽。。。。。。。。。。。"
<< endl;
sockaddr_in addr_client;
int n_size_addr =
sizeof
(addr_client)
; socket socket_client =::
accept
(listen_socket,
(sockaddr*
)&addr_client,
&n_size_addr);if
(invalid_socket == socket_client)
cout <<
"監聽成功。。。"
<<
inet_ntoa
(addr_client.sin_addr)
<< endl;
// 6.收發資料
char szbuffer[
1024]=
;int recv_len =::
recv
(socket_client, szbuffer,
1024,0
);if(recv_len <=0)
::closesocket
(listen_socket)
; listen_socket =0;
wsacleanup()
;return0;
}
#include
using namespace std;
#include
#pragma comment(lib, "ws2_32.lib")
intmain()
if(lobyte
(wsadata.wversion)!=2
||hibyte
(wsadata.wversion)!=2
)else
printf
("the winsock 2.2 dll was found okay\n");
// 2.建立監聽套接字
socket client_socket =::
socket
(af_inet, sock_stream , ipproto_tcp);if
(client_socket == invalid_socket)
// 3.將監聽套接字與本機進行繫結
sockaddr_in addr_client;
addr_client.sin_family = af_inet;
addr_client.sin_addr.s_un.s_addr = inaddr_any;
// 連線本地任意網絡卡
addr_client.sin_port =
htons
(4568);
if(::
bind
(client_socket,
(const sockaddr*
)&addr_client,
sizeof
(sockaddr_in)
)== socket_error)
// 5.監聽成功進行連線
sockaddr_in addr_server;
addr_server.sin_family = af_inet;
addr_server.sin_port =
htons
(4567);
addr_server.sin_addr.s_un.s_addr =
inet_addr
("192.168.3.25");
if(::
connect
(client_socket,
(const sockaddr*
)&addr_server,
sizeof
(sockaddr_in)
)== socket_error)
else
// 6.收發資料
char szbuffer[
1024]=
; cin >> szbuffer;
int send_len =::
recv
(client_socket, szbuffer,
1024,0
);if(send_len <=0)
::closesocket
(client_socket)
; client_socket =0;
wsacleanup()
;return0;
}
作業系統與網路 2019 1 30
void cmodifymemory firstfind dword nfindvalue 6.完成 findonepage 函式,首先用乙個陣列來儲存查詢到的內容 dword sz buffer 1024 7.讀程序位址空間的內容,讀失敗則返回 if 0 readprocessmemory m h...
作業系統與網路 2019 2 1
1.作用域是通過 來進行區分的 2.全域性變數需要使用 來與區域性變數進行區分 同名情況下 3.命名空間是 ansi c 引入的可以由使用者命名的作用域,用來處理程式中常見的同名衝突 4.當只呼叫標頭檔案而沒有開啟命名空間時,某些函式是無法使用的。1.函式的預設值從右到左 右邊有,左邊無 2.函式的...
作業系統與網路 2019 3 25
void cudpnet closenet 解除安裝庫 wsacleanup bool cudpnet senddata ulong uip,const char pszsendbuffer,int nsendlen return true unsigned int stdcall cudpnet ...