karthikeyanr 0 Newbie Poster
#!/usr/bin/perl
# Example of a daytime TCP server using perl functions
use strict;
use Socket qw(INADDR_ANY AF_INET SOMAXCONN SOCK_STREAM sockaddr_in);

# Get protocol number
my $proto = getprotobyname(’tcp’);

# Create generic socket
socket(SOCK, AF_INET, SOCK_STREAM, $proto) or die "socket: $!";

# Bind to the daytime port on any interface
my $port = getservbyname(’daytime’,’tcp’);
my $paddr = sockaddr_in($port, INADDR_ANY);
bind(SOCK, $paddr) or die "bind: $!";

# Notify the kernel we want to accept connections
listen(SOCK, SOMAXCONN) or die "listen: $!";
while(1) {
    if(accept(CLIENT, SOCK)) {
        print CLIENT scalar localtime, "\n";
        close CLIENT;
    }
}

when i run this program i got error like:
Unrecognized character \xE2 at ./server.pl line 6.

How to solve this?