用户工具

站点工具

Action disabled: source

reference:library:ethernetudpbegin

Ethernet :UDP协议类

begin()

描述

初始化ethernet UDP 库并进行网络设置。

语法

EthernetUDP.begin(localPort);

参数

localPortt:所侦听的本地端口(以int型)

返回

例子

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
 
//下面为你的控制器输入MAC地址和IP地址。
// IP地址将依赖于你的本地网络设定:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);
unsigned int localPort = 8888; //所侦听的本地端口
 
//实例化EthernetUDP,使我们可以发送和接收UDP数据包
EthernetUDP Udp;
 
void setup(){
  //启动以太网和UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);
}
 
void loop(){
 
}

返回主菜单

reference/library/ethernetudpbegin.txt · 最后更改: 2023/06/07 04:24 由 127.0.0.1