China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 05:44
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » How to set the listening port and receive data for wattcp UDP? View 1,631 Replies 3
Original Poster Posted 2008-12-02 22:32 ·  中国 广西 柳州 电信
新手上路
Credits 14
Posts 5
Joined 2005-12-15 15:32
20-year member
UID 47200
Status Offline
About wattcp, how to set the listening port and receive data?


#include <stdio.h>
#include <tcp.h>

int main()
{
word status;
word port;
longword host;
udp_Socket usock;

//------//
sock_init();

host=resolve("192.168.1.28";
port=8001;

//--- OPEN UDP ---//
udp_open(&usock,0,host,port,NULL);

//--- SEND DATA ---//
sock_write(&usock,"发送成功!!",10);

//--- CLOSE UDP ---//
sock_close(&usock);

sock_exit();
}


The above program can be successfully sent!! The program on the WINDOWS side has already received it!
But I don't know how to write the receiving module on the DOS side!!!!
So annoying~!!!!!!!!!

Everyone, please help me~!!!! Thank you~!
Floor 2 Posted 2008-12-05 00:03 ·  中国 河北 石家庄 联通
新手上路
Credits 16
Posts 8
Joined 2008-04-18 20:26
18-year member
UID 116275
Gender Male
Status Offline
sock_receive()直接收
Floor 3 Posted 2008-12-05 00:09 ·  中国 河北 石家庄 联通
新手上路
Credits 16
Posts 8
Joined 2008-04-18 20:26
18-year member
UID 116275
Gender Male
Status Offline
```c
int revLen;
char revBuff[1024];
udp_open(&udpSock, localPort, 0, 0, NULL);
tcp_tick(NULL); // Give the protocol stack a chance to execute
if ((revLen = sock_dataready(&udpSock)) != 0) // Check if data has arrived
{
sock_fastread(&udpSock, (byte*)revBuff, revLen); // Receive data
}
```
Floor 4 Posted 2008-12-07 03:51 ·  中国 广西 柳州 融安县 电信
新手上路
Credits 14
Posts 5
Joined 2005-12-15 15:32
20-year member
UID 47200
Status Offline
Thanks to the brother above~!

But the packet loss is too serious~!

Gave up~!

Thanks~!
Forum Jump: