有没有办法我可以同时获取Android中的WiFi和蜂窝网络的IP地址.我尝试使用很多例子,但能够获得只有WiFi网络而不是蜂窝网络的地址.我已启用WiFi和蜂窝网络设备可通过WiFi访问Internet.
这是我用来获取IP地址的代码:
String ipAddress = null;
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
ipAddress = inetAddress.getHostAddress().toString();
Log.i("Here is the Address",ipAddress);
}
}
}
} catch (SocketException ex) {
}
Run Code Online (Sandbox Code Playgroud)
当设备连接到WiFi时,是否有可能获得蜂窝网络的IP地址.如果是,那么这是可行的.
有没有办法在S3 Bucket中完成上传时收到通知?要求是我需要在桶中完成视频上传后提供用户链接.默认情况下,我现在提供视频开始30分钟后的链接,无论视频上传5分钟还是40分钟.那么有没有像任何API那样提供上传已完成的信息?
我在SQL Server Express与字段的表name varchar(10)
和timeVar time
我要保存的值QTime
的变量time
场.
这是我尝试过的:
QTime time = QTime::currentTime();
QString timeString = time.toString("hh:mm:ss");
QString query = QString("insert into timeHold(name,timeVar) values ('ABC','%2')").arg(timeString);
qry->prepare(query);
qry->exec();
Run Code Online (Sandbox Code Playgroud)
但是,我明白了QSqlQuery::value: not positioned on a valid record
.
当我从SQL Server Management Studio将值插入表中时,insert into timeHold values('XYZ', '12:17:35')
效果很好.令我惊讶的是,当我尝试从管理工作室读取存储在表中的值时,我能够获得名称字段,但不能获得时间字段.
这是我用来从表中读取值的代码:
QString query = QString("select * from timeHold");
qry->prepare(query);
qry->exec();
qry->first();
int noOfRecords = qry->numRowsAffected();
do {
qDebug() << qry->value(0).toString();
qDebug() << qry->value(1).toString();
} while (qry->next());
Run Code Online (Sandbox Code Playgroud)
代码生成以下输出:
"ABC"
"\u0017" …
Run Code Online (Sandbox Code Playgroud) 如何获取recv()
套接字通信recv()
返回的错误号或错误字符串,返回-1
读取大小,这意味着发生了一些错误.我想知道错误的具体原因.所以我怎么能得到它.
我正在使用NetBeans IDE中的C应用程序,应用程序基本上是客户端 - 服务器模型.我根据客户端的数据计算一些值,但在特定情况下,值计算失败.而不是返回值为65536我得到的值为256.
以下是这种情况:
int pckt_number = 0; //size of int is 4 bytes.
pckt_number = 0 << 8 ; // 1
pckt_number |= 1 << 8; //2
pckt_number |= 0 << 8 ; //3
pckt_number |= 0; //4
Run Code Online (Sandbox Code Playgroud)
这里从执行中跳过第3和第4个语句,并且返回值为256而不是65536.对于其余的情况,从1到65535计算正确的值.请注意int是4个字节.
c ×2
amazon-s3 ×1
android ×1
c++ ×1
errno ×1
ip-address ×1
linux ×1
netbeans ×1
networking ×1
qt ×1
return-value ×1
strerror ×1