LẬP TRÌNH WINSOCK HUONG DAN LAP TRINH WINSOCK VO!. VISUAL C++... © An application that supports MFC... i =1-C Globals h" a ry mainint ange Insert Project into Workspace..... Khai báo #
Trang 1LẬP TRÌNH WINSOCK
HUONG DAN LAP TRINH WINSOCK VO! VISUAL C++
Trang 2Tao Project mo’
|e Edit View Insert Project Build Tools Window Help
| Glose il] *|| ZS a4 ||£ (ea eee ally
Open Workspace [ƒ
Save Workspace
Glose Workspace
bed Save Ctr|1-5
Save &s,,,
Gi Save ñ||
Page Setup
&# Print CH|+P
Recent Files »
Recent Workspaces >
Exit
Je}, Buia {Debug ) Find in Files 1, Find in Files2 ) Results ) SQL Debugging 7 «| | › fs
Creates a new document, project or workspace
#\start| (2Ì 2ÿ @@ ” C Thuchanh || Microsoft visual C++
(« HE 8) tj 11:17PM
2
Trang 3Chọn Win32 Console Application
218) x)
|| Eile Edit view Insert Project Build Tools Window Help
lÏ# | 8 @ | š m œ | >x c>x lB[m ® | S&j xi“
| zl | xxx ||# ã & 9£ g9
Neu
Files Projects | Workspaces | Other Documents |
oe] ATL COM AppWizard |] Win32 Dynamic-Link Library Project name:
vg | Cluster Resource Type Wizard | Win32 Static Library |TCPServer q<| Custom Appwizard -
=} Database Project Location:
424 DevStudio Add-in Wizard JD:4G T¥TSL4P TRINH MANGST et Extended Stored Proc Wizard
ISAPI Extension Wizard fs] Makefile @ Create new workspace
= MFC ActiveX Controwizard © dd to current workspace (g] MFC App wizard (alll) I Dependency of
fa MFC Appwizard (exe)
GN New Database Wizard
HT) Oracle App\izard for MFC [exe]
Tf Utility Project ;
PA] Win2 Application E00
Fe
Win32 Console Application
>|
[_0œ | Cancel |
ag
-
[4| > E Buid (Debug À Find in Files 1 \ Find in Files2 À Results À SGL Debugging / lal | › fis
@ start| (2 3% Ø C2 muhanh || oo Microsoft Visual C++ _Y untitled - Paint | « SB 11:20PM
3
Trang 4Chon A simple application
TCPServyer - Microsoft Yisual C++
|| Eile Edit view Insert Project Build Tools window Help
| al al xI*x + |||# i4 & 1 oo
Win32 Console Application - Step 1 of 1
What kind of Console Application do you want to create?
An empty project
© & simple application
™ &"Hello, World!" application
© An application that supports MFC
New> | | Fimsh | Cancel |
af
e}\ Build {Debug }, Find in Files 1) Find in Files2 \ Results } SQL Debugging / a] i |
Ready
@start| (3 2 B® ” C2 Thuchanh [oo TCPServer - Microsoft w untitled - Paint | (3 My Computer | < Chm y yg 11:23PM
Trang 5Khai báo sử dụng thư viện winsock
TCPServer - Microsoft ¥isual C++ - [TCPServer.cpp]
llE File Edit View Insert project Build Tools Window Help -|#| x|
fa | LG | ¥ B Set Active Project › lại XI “an
J Add To Project › ¬ & ca
[(Globats) ` h xv v | itt)
jJes 3 Dependencies a : :
———— mm Ề Defines the entry point for the console application =
= B8 TCPServer class Export Makefile i
=1-C Globals h"
a ry main(int ange Insert Project into Workspace
int main(int argc, char* argv[]) return 0:
"Hid ClaseView |] FileView | Ia] |
Xl[Tinking
[J > ]\ Build {Debug } Find in Files 1), Find in Files2 }, Results À SQL Debugging / | f Edits the project build and debug settings [Ln9,Coli4 [REC {COL OVA [READ
@start| (3 oe 2 3 `3 Thuchanh [oo TCPServer - Microsoft _w untitled - Paint | (9 My Computer | le Ss * = J 11:24 PM 5 TCPServer.exe — 0 error(s), 0 warning({s)
a 86
ng
Trang 6
Thư viện sử dung là wsock32.lib
là 8g : 5
|[Eksa3 —Elamm XxIÑ+ *
: Defines the entry point ‘for
=e TCPServer classes |
Ei-C Giobals
be ol mainfint arqc, char,
Debug/TCPServer.exe |
ib oleaut32.lib uuid.lib adbc32.lib adbccp32.lib AE
adyapi32 lib shell32.lib ole32.lib oleaut32.lib uuid lib — adbc32.lib adbccp32.lib: kernel32.lib user32.lib qdi32.lïb v
inking
TCPServer.exe - 0 error(s) 0 warning({s)
nd in
Trang 7Khai báo #include <winsock.h> trong code
tinclude <winsock.h>
int main(int argc, char* argv[])
{
WSADATA wsaData;
eee
code here
return 0;