创客百科

姿势共享,有节操无门槛参与的创客百科,创客动力之源 \ (^_^) /

用户工具

站点工具


arduino:libraries: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(){
 
}

返回主菜单

本页面的其他翻译:
arduino/libraries/ethernetudpbegin.txt · 最后更改: 2016/12/25 22:15 (外部编辑)