I have normal server code here, and i have no idea how to make it work with many clients. The server would print what one client says to every client. - #!/usr/bin/perl -w
-
use IO::Socket::INET;
-
use strict;
-
-
my $port = '1584';
-
-
my $socket = IO::Socket::INET->new('LocalPort' => $port,
-
'Proto' => 'tcp',
-
'Listen' => SOMAXCONN)
-
or die "Can't create socket ($!)\n";
-
print "[Server created at port:$port]\n";
-
while (my $client = $socket->accept) {
-
$client->autoflush(1);
-
my $name = gethostbyaddr($client->peeraddr, AF_INET);
-
printf "[Connect from %s]\n", $client->peerhost;
-
my $port = $client->peerport;
-
while (<$client>) {
-
print "[$name $port] $_";
-
print $client "[$name $port] $_";
-
}
-
close $client
-
or die "Can't close ($!)\n";
-
}
-
die "Can't accept socket ($!)\n";
9 3427 KevinADC 4,059
Recognized Expert Specialist
This seems like a script kiddy, script at least part of it,
and from the previous post he/she has posted it looks like it,
I am not sure what a script kiddy is or what your implication is. The code looks benign to me, I don't know how to answer his question though.
Icecrack 174
Recognized Expert New Member
Can i ask what is this being used for, and we don't understand what you mean
im making a chat script so clients can connect to one server and speak in there, now it works with only with 2 persons so every person who want chat would need to make own servers and get the own clients to other person servers
and then the desktop will be full of those command prompt windows
Icecrack 174
Recognized Expert New Member
im making a chat script so clients can connect to one server and speak in there, now it works with only with 2 persons so every person who want chat would need to make own servers and get the own clients to other person servers
and then the desktop will be full of those command prompt windows
is that the whole script??, i would like to look at the client script
because from what i have followed up on this it should accept more then one connection.
Here is the client script - #!/usr/bin/perl
-
#didnt make this
-
use IO::Socket::INET;
-
use strict;
-
-
my $name = 'localhost';
-
my $port = '1584';
-
-
my $socket = IO::Socket::INET->new('PeerAddr' => $name,
-
'PeerPort' => $port,
-
'Proto' => 'tcp')
-
or die "Can't create socket ($!)\n";
-
print "Client sending\n";
-
while (<STDIN>) {
-
print $socket $_;
-
print scalar <$socket>;
-
}
-
close $socket
-
or die "Can't close socket ($!)\n";
The problem is when i connect the server with 2 clients, the server prints that "127.0.0.1 has connected" only once and when i try to send something with the other client the server wont print it
Icecrack 174
Recognized Expert New Member
Here is the client script - #!/usr/bin/perl
-
#didnt make this
-
use IO::Socket::INET;
-
use strict;
-
-
my $name = 'localhost';
-
my $port = '1584';
-
-
my $socket = IO::Socket::INET->new('PeerAddr' => $name,
-
'PeerPort' => $port,
-
'Proto' => 'tcp')
-
or die "Can't create socket ($!)\n";
-
print "Client sending\n";
-
while (<STDIN>) {
-
print $socket $_;
-
print scalar <$socket>;
-
}
-
close $socket
-
or die "Can't close socket ($!)\n";
The problem is when i connect the server with 2 clients, the server prints that "127.0.0.1 has connected" only once and when i try to send something with the other client the server wont print it
I'm Testing your code will get back to you shortly,
thanks
Icecrack 174
Recognized Expert New Member
I'm Testing your code will get back to you shortly,
thanks
sorry im still looking at your code and testing this...
KevinADC 4,059
Recognized Expert Specialist
The code should not compile, I spotted at least one syntax error:
That should probably be: Icecrack 174
Recognized Expert New Member
The code should not compile, I spotted at least one syntax error:
That should probably be:
it does compile Kevin, i have tested it, i think its more to do with the port being used on one computer im trying to test this not on the same machine (Server on one, 2 clients on 2 other machines)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: j.a. harriman |
last post by:
Hi,
On MSDN I know there is a JScript example (Upgrading Visual C++ Projects to
Visual Studio .NET in Batch Mode) to upgrade VS6 C++ projects to .NET
solutions.
It converts the project files...
|
by: D |
last post by:
Hey guys- not sure where this post fits in, so I cc'd a few other groups as
well- hope you dont mind...
I have someone creating a database for me in Access 2000 (or is it called
XP?). When it's...
|
by: Robert |
last post by:
I have a series of web applications (configured as separate applications) on
a server.
There is a main application at the root and then several virtual directories
that are independant...
|
by: Klaus Jensen |
last post by:
Hi!
In this code...:
Dim oAsciiStreamWriter As New StreamWriter("C:\Temp\TestAscii.txt", False,
System.Text.ASCIIEncoding.ASCII)
oAsciiStreamWriter.WriteLine("Test of danish chars - ÆØÅæøå")...
|
by: Sharon |
last post by:
I have a buffer of byte that contains a raw data of a 1 byte-per-pixel
image data.
I need to convert this buffer to a Bitmap of Format32bppArgb and to a Bitmap
of Format24bppRgb.
Can anybody...
| |
by: Man-wai Chang |
last post by:
Must I use CSS to layout the pages?
--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.06) ...
|
by: shineofleo |
last post by:
Here is the situation: I wrote a VB programm, which stores all the
information in a single Access database file using jet engine. It
worked well, however one of my customs reported that there was...
|
by: DBuss |
last post by:
OK, I'm reading a multicast socket. It attaches fine, reads fine, all of that.
The problem is that while some of the data I get is normal text (ASCII String), some of it is Binary Integer.
...
|
by: John Brown |
last post by:
Hi there,
Does anyone know how to go about reading/writing a type to a file in a
language (culture) independent way. For instance, let's say you're dealing
with the native "System.Drawing.Size"...
|
by: Slain |
last post by:
I need to convert a an array to a multidimensional one. Since I need
to wrok with existing code, I need to modify a declaration which looks
like this
In the .h file
int *x;
in a initialize...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |