commit b5548db730268e18c1e9514aaa389feeb7d0cd19
parent 3920079757a83f1171829ac78093de9352b7c4bb
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Sat, 23 May 2015 21:59:31 -0600
sl: fix indendation, add basic network support
Diffstat:
M | sl | | | 46 | ++++++++++++++++++++++++++++++++-------------- |
1 file changed, 32 insertions(+), 14 deletions(-)
diff --git a/sl b/sl
@@ -1,15 +1,16 @@
#!/usr/bin/perl -w
-use warnings
-use strict
+use warnings;
+use strict;
use DBI;
+use IO::Socket;
my $dbh = DBI->connect(
- "dbi:SQLite:dbname=db",
- "",
- "",
- { RaiseError => 1 }
+ "dbi:SQLite:dbname=db",
+ "",
+ "",
+ { RaiseError => 1 }
) or die $DBI::errstr;
$dbh->do(qq{create table if not exists contacts(
@@ -18,13 +19,30 @@ $dbh->do(qq{create table if not exists contacts(
}) or die $DBI::errstr;
$dbh->do(qq{create table if not exists list_data(
- list_id int not null,
- position int not null,
- text text not null,
- status int not null default 0,
- owner int not null,
- primary key(list_id, position),
- foreign key(owner) references contacts(phone_num)
+ list_id int not null,
+ position int not null,
+ text text not null,
+ status int not null default 0,
+ owner int not null,
+ primary key(list_id, position),
+ foreign key(owner) references contacts(phone_num)
)}) or die $DBI::errstr;
-$dbh->do(qq{create table if not exists user_list(
+# $dbh->do(qq{create table if not exists user_list(
+
+my $sock = new IO::Socket::INET (
+ LocalHost => '0.0.0.0',
+ LocalPort => '5437',
+ Proto => 'tcp',
+ Listen => 1,
+ Reuse => 1,
+);
+
+die "Could not create socket: $!\n" unless $sock;
+
+my $new_sock = $sock->accept();
+
+while(<$new_sock>) {
+ print $_;
+}
+close($sock);