我已经有很长一段时间没有得到这个错误了,谷歌也没有多少帮助.
我是Winsock编程的新手,并试图从在线资源中学习.我正在尝试使用MSDN网站上的详细信息构建一个简单的服务器.每当我编译代码(MinGW)时,我都会收到标题(Undefined reference to getaddrinfo
)中提到的错误.以下是代码:
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#define WINVER WindowsXP
#include <windows.h>
#include <winsock2.h>
#include <winsock.h>
#include <ws2tcpip.h>
#include <stdio.h>
int main() {
WSADATA wsaData;
int iResult;
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult != 0) {
printf("WSAStartup failed: %d\n", iResult);
return 1;
}
#define DEFAULT_PORT "27015"
struct addrinfo *result = NULL, *ptr = NULL, hints;
ZeroMemory(&hints, sizeof (hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
// Resolve the local address …
Run Code Online (Sandbox Code Playgroud) 有一次,我遇到过很多关于使用C++不适合SSS的东西,并建议使用所谓的解释语言,如PERL和PHP.但我需要先进的OO功能和C++的灵活性,以确保可扩展且更易于管理的代码.
我已经尝试了很多互联网文章和搜索,没有任何一个有用的地方,我仍然不知道是否有可能用C++编写SS-Scripts,如果是,那么如何.
我想到了几个想法,包括用C++编写Web服务器并在解析HTTP请求后做出相应的响应.但它会重新发明轮子,我最终会偏离我的主要项目并投入大量精力来确保功能兼安全的HTTP服务器.
我也考虑过PHP扩展,但这种方法也带有自己的包袱和开销.
我的问题是:
谢谢!
可以说,代码看起来像这样:
if(!$test) {
header("Location: somefile.html");
...some PHP code....
header("Location: anotherfile.html");
}
Run Code Online (Sandbox Code Playgroud)
上面有'某些PHP代码'吗?如果是,那么其中的HTTP响应会发生什么(例如:代码中的第二个'header'语句)?
寻找有助于"进入"Linux代码的资源.无法在Google上获得太多帮助.我对本书/资源所涵盖的发行版没有任何问题,但是如果Fedora是基础的话,我会很感兴趣.此外,如果资源得到良好维护和更新,那将是很好的.
我正在编写的应用程序在某个阶段生成一个CharacterList字符.在这个阶段,我正在尝试创建一个线程来处理这个ArrayList.问题是如何将此ArrayList传递给线程
描述代码:
class thisApp {
/* Some initial processing creates an ArrayList - aList */
Runnable proExec = new ProcessList (); //ProcessList implements Runnable
Thread th = new Thread(proExec);
}
Run Code Online (Sandbox Code Playgroud)
ProcessList的描述性代码:
public class ProcessList implements Runnable {
public void run() {
/* Access the ArrayList - aList - and do something upon */
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何在run()中传递和访问aList?
$("#popMenu-fk").load("secure/student.php");
Run Code Online (Sandbox Code Playgroud)
当php脚本位于"a/Secure"文件夹中时,调用文件位于文件夹"a"中.但是,我无法从该路径访问该文件,但是如果我将该文件粘贴到与调用文件相同的文件夹中并使用
$("#popMenu-fk").load("student.php");
Run Code Online (Sandbox Code Playgroud)
有用!
我在某个地方出错了吗?谢谢!
即使fopen()函数成功执行,此代码也始终返回-1.有什么我无视的东西.
void nullCheck(FILE* checkVar) {
if(checkVar==NULL) {
#define _NULL_ERROR
}
}
int readFile(char* _name, char* storeArray) {
FILE* fp;
fp=fopen(_name,READ_ONLY_MODE);
nullCheck(fp);
#ifndef _NULL_ERROR
char c=0;
while((c=getc(fp))!=EOF) {
*(storeArray+i)=c;
i+=1;
}
#endif
#ifdef _NULL_ERROR
#undef _NULL_ERROR
return -1;
#endif
return 1;
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
如何在不定义函数大小的情况下传递二维或多维数组作为函数的参数?
这是我的示例代码:
void test(int *a) {
a[0][0] = 100;
}
int main() {
int a[2][2];
test(a);
cout<<a[0][0];
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试这样的事情:
var usernameDone = false;
/*Some application logic*/
alert(usernameDone);
Run Code Online (Sandbox Code Playgroud)
这总是在评估undefined
.但是,如果我将变量名称更改usernameDone
为其他任何名称,即使usrnameDone
脚本也能正常工作.是否usernameDone
冲突与jQuery?如果没有,那为什么会发生?
(我目前正在使用jQuery-1.6.1在Chrome上进行测试,但尚未尝试其他浏览器.)
[更新]即使消除了应用程序逻辑
,变量undefined
也会计算.
[更新-2完整代码]
我已使用//
注释标记了用法
$('document').ready( function() {
/**
* The following set manages the effects for the login menu. The effects including highlighting
* the login box when focused, showing guidance through a pop-up menu and handling transformation
* through fade effects.
*
*/
var usernameDone = false; //Declared here
/**
* @function login-box focus()
* …
Run Code Online (Sandbox Code Playgroud)