🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
1 messages
1 total messages Started by Nitro Tue, 09 Nov 2004 23:06
Threads en shared variabele
#1965
Author: Nitro
Date: Tue, 09 Nov 2004 23:06
39 lines
2068 bytes
ik heb een aantal threads, en ik wil dat die allemaal dezelfde hashmap
gebruiken. Dit gaat met shared. 

Nu wil ik echter in die hashmap handles van netwerkverbindingen steken.
Hier gaat het mis: "thread failed to start: Can't upgrade that kind of
scalar at ./test.pl line 19." is het resultaat.

Laat ik die shared weg werkt het, maar heb ik geen gesharede hashmap.


Iemand een suggestie

Nitro


PS Niet letten op "onchristelijkheden", dit is maar rap in elkaar geflanst.



#!/usr/bin/perl

use warnings;
use strict;
use Socket;
use threads;
use threads::shared;

my %hash : shared;
socket(my $socket, PF_INET, SOCK_STREAM, getprotobyname('tcp')) or die "Error creating TCP-socket\n";
bind($socket, sockaddr_in(1863, INADDR_ANY)) or die "Error binding to port 1863\n";
listen($socket, 10) or die "Cannot listen at defined socket\n";
accept(my $client, $socket);
threads->new( sub { test($client)});

sub test{
my($conn) = @_;
$hash{"client"} = $conn;
print("$hash{'client'}\n");
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads