小编Ben*_*ash的帖子

Python'连接重置由同行'

我正在玩Python并在给定端口上监听UDP数据包,一切似乎都运行良好 - 但是经过一段时间后,脚本崩溃并出现以下错误:

data = self._sock.recv(self._rbufsize)
socket.error: [Errno 54] Connection reset by peer
Run Code Online (Sandbox Code Playgroud)

仅重新启动脚本时,在较短的时间后再次发生同样的崩溃.重新启动服务器似乎再次彻底解决了问题.

关于套接字方面,我正在做:

UDP_IP = "0.0.0.0"
UDP_PORT = 6000

sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind( (UDP_IP, UDP_PORT) )
Run Code Online (Sandbox Code Playgroud)

我错过了一些明显的东西,还是只是一种避免这种情况的简单方法?

提前感谢您可以放下任何光线!

石磊

python sockets udp

10
推荐指数
1
解决办法
2万
查看次数

Python请求 - 发布带有multipart/form-data的zip文件

我正在使用迄今为止令人高兴的Python Requests模块.

但是,我在尝试使用multipart/form-data发布zip文件时遇到了问题.

我正在使用摘要式身份验证,并且能够成功发布其他文件类型,例如.xls等.

我正在创建一个帖子请求:

file = open('/Users/.../test.zip', 'rb').read()
r = requests.post(url, auth=HTTPDigestAuth('dev', 'dev'), data = {"mysubmit":"Go"}, files={"archive": ("test.zip", file)})
Run Code Online (Sandbox Code Playgroud)

这错误并给出:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.2.2.70', port=80): Max retries exceeded with url: /plugin_install 
(Caused by <class 'socket.error'>: [Errno 32] Broken pipe)
Run Code Online (Sandbox Code Playgroud)

我尝试使用较小的zip文件并更改数据/文件值,并发生相同的错误.

我错过了一些明显的东西吗

感谢您可以放下任何光线!

python post python-requests

5
推荐指数
1
解决办法
2万
查看次数

UITableView pushViewController选择一行

我正在用UITableView构建一个iPhone应用程序.在选择一行时,我希望在加载特定URL时推送UIWebView.

我目前有:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
NSDictionary * story = [stories objectAtIndex:[indexPath row]]; 
NSString * storyLink = [NSString stringWithFormat:[story objectForKey:@"link"]];

    [[self navigationController] pushViewController:[[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]] animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

如何通过以下方式获取滑入的新视图以包含UIWebView并随后将故事链接加载到其中:

loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:storyLink]]
Run Code Online (Sandbox Code Playgroud)

提前致谢,

石磊

iphone cocoa-touch objective-c uitableview uinavigationcontroller

4
推荐指数
1
解决办法
2万
查看次数

UITableView从NSMutableArray/NSDictionary循环输出数据

我目前正在构建一个iPhone应用程序,它将显示来自名为"故事"的NSMutableArray的数据.数组结构如此(通过NSLog):

    2009-07-20 12:38:30.541 testapp[4797:20b] (
    {
    link = "http://www.testing.com";
    message = "testing";
    username = "test";
},
    {
    link = "http://www.testing2.com";
    message = "testing2";
    username = "test2";
} )
Run Code Online (Sandbox Code Playgroud)

我的cellForRowAtIndexPath目前看起来像这样:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];


}

    for (NSDictionary *story in stories) {
        [cell setTextColor:[UIColor whiteColor]];
        [cell setFont: [UIFont systemFontOfSize:11]];
        cell.text = [NSString stringWithFormat:[story objectForKey:@"message"]];
    }
            return cell; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uitableview nsarray

0
推荐指数
1
解决办法
9098
查看次数