| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 788 人关注过本帖
标题:[结贴]会WINSOCKAPI编程的进....
只看楼主 加入收藏
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
 问题点数:0 回复次数:9 
[结贴]会WINSOCKAPI编程的进....

不知不觉必须要用WINSOCKAPI开始编程了.自己还不懂用的方法.
甚至连那些函数都不懂.
想请大家帮忙弄WINSOCKAPI的函数的用法和一个普通的例子就可以了...
如果有教程 当然就更好了.
现贴WINSOCKAPI的基本函数....大家帮忙啊,不说话就代表这里没人来了...
Declare Function getsockname Lib "ws2_32.DLL" (ByVal s As Long, sname As sockaddr, namelen As Long) As Long
Declare Function WSAStartup Lib "ws2_32.DLL" (ByVal wVR As Long, lpWSAD As WSADataType) As Long
Declare Function WSACleanup Lib "ws2_32.DLL" () As Long
Declare Function bind Lib "ws2_32.DLL" (ByVal s As Long, addr As sockaddr, ByVal namelen As Long) As Long
Declare Function accept Lib "ws2_32.DLL" (ByVal s As Long, addr As sockaddr, namelen As Long) As Long
Declare Function socket Lib "ws2_32.DLL" (ByVal af As Long, ByVal s_type As Long, ByVal protocol As Long) As Long
Declare Function WSASocket Lib "ws2_32.DLL" Alias "WSASocketA" (ByVal af As Long, ByVal s_type As Long, ByVal protocol As Long, lpProtocolInfo As Any, ByVal g As Long, ByVal dwFlags As Long) As Long
Declare Function closesocket Lib "ws2_32.DLL" (ByVal s As Long) As Long
Declare Function connect Lib "ws2_32.DLL" (ByVal s As Long, addr As sockaddr, ByVal namelen As Long) As Long
Declare Function gethostbyname Lib "ws2_32.DLL" (ByVal host_name As String) As Long
Declare Function gethostbyaddr Lib "ws2_32.DLL" (addr As Any, ByVal nlen As Long, ByVal ntype As Long) As Long
Declare Function gethostname Lib "ws2_32.DLL" (ByVal host_name As String, ByVal namelen As Long) As Long
Declare Function recv Lib "ws2_32.DLL" (ByVal s As Long, Buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long
Declare Function recvfrom Lib "ws2_32.DLL" (ByVal s As Long, Buf As Any, ByVal buflen As Long, ByVal flags As Long, from As sockaddr, fromlen As Long) As Long
Declare Function send Lib "ws2_32.DLL" (ByVal s As Long, Buf As Any, ByVal buflen As Long, ByVal flags As Long) As Long
Declare Function sendto Lib "ws2_32.DLL" (ByVal s As Long, Buf As Any, ByVal buflen As Long, ByVal flags As Long, to_addr As Any, ByVal tolen As Long) As Long
Declare Function htonl Lib "ws2_32.DLL" (ByVal hostlong As Long) As Long
Declare Function htons Lib "ws2_32.DLL" (ByVal hostshort As Long) As Integer
Declare Function ntohs Lib "ws2_32.DLL" (ByVal netshort As Long) As Integer
Declare Function ntohl Lib "ws2_32.DLL" (ByVal netlong As Long) As Long
Declare Function inet_addr Lib "ws2_32.DLL" (ByVal cp As String) As Long
Declare Function inet_ntoa Lib "ws2_32.DLL" (ByVal in_n As Long) As Long
Declare Function setsockopt Lib "ws2_32.DLL" (ByVal s As Long, ByVal level As Long, ByVal optname As Long, optval As Long, ByVal optlen As Long) As Long
Declare Function setsockopt2 Lib "ws2_32.DLL" Alias "setsockopt" (ByVal s As Long, ByVal level As Long, ByVal optname As Long, optval As Any, ByVal optlen As Long) As Long
Declare Function getsockopt Lib "ws2_32.DLL" (ByVal s As Long, ByVal level As Long, ByVal optname As Long, optval As Long, optlen As Long) As Long
Declare Function getsockopt2 Lib "ws2_32.DLL" Alias "getsockopt" (ByVal s As Long, ByVal level As Long, ByVal optname As Long, optval As Any, optlen As Long) As Long
Declare Function listen Lib "ws2_32.DLL" (ByVal s As Long, ByVal backlog As Long) As Long
Declare Function WSAIoctl Lib "ws2_32.DLL" (ByVal s As Long, ByVal dwIoControlCode As Long, lpvInBuffer As Any, ByVal cbInBuffer As Long, lpvOutBuffer As Any, ByVal cbOutBuffer As Long, lpcbBytesReturned As Long, lpOverlapped As Any, lpCompletionRoutine As Any) As Long
Declare Function WSAEnumProtocols Lib "ws2_32.DLL" Alias "WSAEnumProtocolsA" (ByVal lpiProtocols As Long, ByVal lpProtocolBuffer As Long, lpdwBufferLength As Long) As Long
Declare Function WSAGetLastError Lib "ws2_32.DLL" () As Long
Declare Function WSACreateEvent Lib "ws2_32.DLL" () As Long
Declare Function WSACloseEvent Lib "ws2_32.DLL" (ByVal hEvent As Long) As Boolean
Declare Function WSAEventSelect Lib "ws2_32.DLL" (ByVal s As Long, ByVal hEventOjbect As Long, ByVal lNetWorkEvents As Long) As Long
Declare Function WSAEnumNetworkEvents Lib "ws2_32.DLL" (ByVal s As Long, ByVal hEventOjbect As Long, lpNetWorkEvents As WSANETWORKEVENTS) As Long
Declare Function WSAWaitForMultipleEvents Lib "ws2_32.DLL" (ByVal cEvents As Long, lphEvents As Long, ByVal fWaitAll As Boolean, ByVal dwTimeOUT As Long, ByVal fAlertable As Boolean) As Long
Declare Function WSAResetEvent Lib "ws2_32.DLL" (ByVal hEvent As Long) As Boolean
Declare Function WSAEnumNameSpaceProviders Lib "ws2_32.DLL" Alias WSAEnumNameSpaceProvidersA" (lpdwBufferLength As Long, ByVal lpnspBuffer As Long) As Boolean


[此贴子已经被作者于2006-8-5 8:25:49编辑过]

搜索更多相关主题的帖子: WINSOCKAPI Long 函数 Lib 
2006-08-03 15:31
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 

会的别害羞啊 ,进来帮忙啊....


[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-08-04 08:34
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 

首先是服务器和客户端都有..
WSAStartup 和 WSACleanup  初始化和清理
接着是socket 函数建立断口和地址
closesocket 函数
服务器端接着用BIND函数 套接字绑定
listen 监听
ACCEPT 接受请求
recv 接收信息
send 发送信息
客户端先建立SOCKET
接着用CONNECT 连接
等服务器接受以后来个RECV接着就可以用send函数通信了.
WINSOCKAPI功能比winsock功能强大的多,更适合质量要求高的网络.


[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-08-04 10:18
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
尤其是用API可以建立一个客户端标识,可以连接很多客户端.
可以指定缓冲区的大小.不用WINSOCK那样只有8K的数据了..

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-08-04 10:21
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
大家帮忙补充啊   我还要具体用呢?谢谢了...

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-08-04 12:14
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
收藏
得分:0 
这些 api 你哪里找的?
2006-08-04 12:24
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
网上啊  这些API是WINDOW的基本API吧.
打包不用放在一起的.

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-08-04 12:28
leon2
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:731
专家分:0
注 册:2005-3-18
收藏
得分:0 
vb 自带API 浏览器没有这些函数的,所以看起来很“新奇”……声明一下我对网络通信就想到 winsock,不懂 WINSOCKAPI。

http://www.china-askpro.com 这是专门解决编程问题的网站,你可以去 vb 的网络通信里看一下有没有你想问的
2006-08-04 12:37
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 

好的 谢谢


[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2006-08-04 12:55
wuming1014
Rank: 1
等 级:新手上路
帖 子:34
专家分:0
注 册:2006-10-6
收藏
得分:0 
以下是引用leon2在2006-8-4 12:37:07的发言:
vb 自带API 浏览器没有这些函数的,所以看起来很“新奇”……声明一下我对网络通信就想到 winsock,不懂 WINSOCKAPI。

http://www.china-askpro.com 这是专门解决编程问题的网站,你可以去 vb 的网络通信里看一下有没有你想问的

很好的网站,我的问题也在里面找到答案了!


2006-10-20 16:05
快速回复:[结贴]会WINSOCKAPI编程的进....
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027411 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved