www.digitalmars.com         C & C++   DMDScript  

D - Socket library for Win32 and Linux

reply Vathix <vathix dprogramming.com> writes:
Attached my code. I tried to make it work for linux but was unable to 
test it, I don't know much about linux. I get this error when running 
dmd on debian:
./dmd: error while loading shared libraries: libstdc++.so.5: cannot open 
shared object file: No such file or directory
I tried to install libstdc++ libs but the error remains.

I'd appreciate it if someone could help by getting the code to work for 
linux or helping me fix my problem :)


-- 
Christopher E. Miller
www.dprogramming.com
irc.dprogramming.com #D
Feb 27 2004
parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
Vathix wrote:
 Attached my code. I tried to make it work for linux but was unable to
 test it, I don't know much about linux. I get this error when running
 dmd on debian:
 ./dmd: error while loading shared libraries: libstdc++.so.5: cannot
 open shared object file: No such file or directory
 I tried to install libstdc++ libs but the error remains.
From my own experience, that means you have to update a lot of things, not only that one, and with very recent versions.
 I'd appreciate it if someone could help by getting the code to work
 for linux or helping me fix my problem :)


 --
 Christopher E. Miller
 www.dprogramming.com
 irc.dprogramming.com #D
I've attached a slightly modified socket.d. From what I can remember: - version(linux) instead of Linux - declared fd_set for BsdSockets - blocking in Socket class was only defined for Windows, although being used in both versions. Commented out the line - errno declared as extern(C) I think that's it. ----------------------- Carlos Santander Bernal8 begin 666 socket.d M;W5T(&%N>2!E>'!R97-S(&]R(&EM<&QI960-" EW87)R86YT>2X ($EN(&YO M(&5V96YT('=I;&P =&AE(&%U=&AO<G, 8F4 :&5L9"!L:6%B;&4 9F]R(&%N M=V%R92X-" D-" E097)M:7-S:6]N(&ES(&=R86YT960 =&\ 86YY;VYE('1O M('5S92!T:&ES('-O9G1W87)E(&9O<B!A;GD <'5R<&]S92P-" EI;F-L=61I M;F< 8V]M;65R8VEA;"!A<'!L:6-A=&EO;G,L(&%N9"!T;R!A;'1E<B!I="!A M;VQL;W=I;F< <F5S=')I8W1I;VYS. T*"0T*"3$N(%1H92!O<FEG:6X ;V8 M=&AI<R!S;V9T=V%R92!M=7-T(&YO="!B92!M:7-R97!R97-E;G1E9#L >6]U M;F%L('-O9G1W87)E+B!)9B!Y;W4 =7-E('1H:7, <V]F='=A<F4-" D ("!I M;B!A('!R;V1U8W0L(&%N(&%C:VYO=VQE9&=M96YT(&EN('1H92!P<F]D=6-T M(&1O8W5M96YT871I;VX =V]U;&0 8F4-" D ("!A<'!R96-I871E9"!B=70 M:7, ;F]T(')E<75I<F5D+ T*"3(N($%L=&5R960 <V]U<F-E('9E<G-I;VYS M(&UU<W0 8F4 <&QA:6YL>2!M87)K960 87, <W5C:"P 86YD(&UU<W0 ;F]T M('-O9G1W87)E+ T*"3,N(%1H:7, ;F]T:6-E(&UA>2!N;W0 8F4 <F5M;W9E M8VME=%]T(#T M" ET>7!E9&5F(&EN="!S;V-K971?=" ]("TQ.PT*?0T*96QS90T*>PT*"7-T M871I8R!A<W-E<G0H,"D[("\O($YO('-O8VME="!S=7!P;W)T('EE= T*?0T* M8V]N<W0 <V]C:V5T7W0 24Y604Q)1%]33T-+150 /2!S;V-K971?="YI;FET M:&%R('-Z4WES=&5M4W1A='5S6U=305-94U]35$%455-?3$5.*S%=.PT*"0D) M=7-H;W)T(&E-87A3;V-K971S.PT*"0D)=7-H;W)T(&E-87A59'!$9SL-" D) M"6-H87(J(&QP5F5N9&]R26YF;SL-" D)?0T*"0EA;&EA<R!74T%$051!*B!, M:6YT(&9D7V-O=6YT.PT*"0D)+R\ 3B!S;V-K971?="=S(&-R96%T960 ;VXM M.#L-" D)8V]N<W0 =6EN="!)3D%$1%)?3D].12 ](" P>$9&1D9&1D9&.PT* M960L($Q05U-!1$%402!L<%=3041A=&$I.PT*"0EI;G0 5U-!0VQE86YU<" I M.PT*"0ES;V-K971?="!S;V-K970H:6YT(&%F+"!I;G0 ='EP92P :6YT('!R M;W1O8V]L*3L-" D):6YT(&EO8W1L<V]C:V5T*'-O8VME=%]T(',L(&EN="!C M;60L('5I;G0J(&%R9W I.PT*"0EI;G0 9V5T<V]C:V]P="AS;V-K971?="!S M+"!I;G0 ;&5V96PL(&EN="!O<'1N86UE+"!C:&%R*B!O<'1V86PL(&EN="H M;W!T;&5N*3L-" D)=6EN="!I;F5T7V%D9'(H8VAA<BH 8W I.PT*"0EI;G0 M8FEN9"AS;V-K971?="!S+"!S;V-K861D<BH ;F%M92P :6YT(&YA;65L96XI M.PT*"0EI;G0 8V]N;F5C="AS;V-K971?="!S+"!S;V-K861D<BH ;F%M92P M:6YT(&YA;65L96XI.PT*"0EI;G0 ;&ES=&5N*'-O8VME=%]T(',L(&EN="!B M86-K;&]G*3L-" D)<V]C:V5T7W0 86-C97!T*'-O8VME=%]T(',L('-O8VMA M9&1R*B!A9&1R+"!I;G0J(&%D9')L96XI.PT*"0EI;G0 8VQO<V5S;V-K970H M:&]W*3L-" D):6YT(&=E='!E97)N86UE*'-O8VME=%]T(',L('-O8VMA9&1R M*B!N86UE+"!I;G0J(&YA;65L96XI.PT*"0EI;G0 9V5T<V]C:VYA;64H<V]C M="!S96YD*'-O8VME=%]T(',L('9O:60J(&)U9BP :6YT(&QE;BP :6YT(&9L M86=S*3L-" D):6YT('-E;F1T;RAS;V-K971?="!S+"!V;VED*B!B=68L(&EN M="!L96XL(&EN="!F;&%G<RP <V]C:V%D9'(J('1O+"!I;G0 =&]L96XI.PT* M"0EI;G0 <F5C=BAS;V-K971?="!S+"!V;VED*B!B=68L(&EN="!L96XL(&EN M=68L(&EN="!L96XL(&EN="!F;&%G<RP <V]C:V%D9'(J(&9R;VTL(&EN="H M9&9D<RP 9F1?<V5T*B!W<FET969D<RP 9F1?<V5T*B!E<G)O<F9D<RP =&EM M(',L(&EN="!L979E;"P :6YT(&]P=&YA;64L('9O:60J(&]P='9A;"P :6YT M*B!O<'1L96XI.PT*"0EI;G0 <V5T<V]C:V]P="AS;V-K971?="!S+"!I;G0 M;&5V96PL(&EN="!O<'1N86UE+"!V;VED*B!O<'1V86PL(&EN="!O<'1L96XI M(" (" -#L- M7U]F9%]M87-K.PH)"6-O;G-T(&EN="!?7TY&1$))5%, /2 S,CLO+S J7U]F M" H)"7-T<G5C="!F9%]S970 >PH)"0E?7V9D7VUA<VL 6R!?7T9$7U-%5%-) M6D4 +R!?7TY&1$))5%, 72!F9'-?8FET<SL*"0E]" H-" D)<V]C:V5T7W0 M="!F8VYT;"AS;V-K971?="!S+"!I;G0 9BP +BXN*3L-" D):6YT(&=E='-O M8VMO<'0H<V]C:V5T7W0 <RP :6YT(&QE=F5L+"!I;G0 ;W!T;F%M92P 8VAA M87(J(&-P*3L-" D):6YT(&)I;F0H<V]C:V5T7W0 <RP <V]C:V%D9'(J(&YA M;64L(&EN="!N86UE;&5N*3L-" D):6YT(&-O;FYE8W0H<V]C:V5T7W0 <RP M<V]C:V%D9'(J(&YA;64L(&EN="!N86UE;&5N*3L-" D):6YT(&QI<W1E;BAS M;V-K971?="!S+"!S;V-K861D<BH 861D<BP :6YT*B!A9&1R;&5N*3L-" D) M:6YT(&-L;W-E*'-O8VME=%]T(',I.PT*"0EI;G0 <VAU=&1O=VXH<V]C:V5T M+"!S;V-K861D<BH ;F%M92P :6YT*B!N86UE;&5N*3L-" D):6YT(&=E='-O M8VMN86UE*'-O8VME=%]T(',L('-O8VMA9&1R*B!N86UE+"!I;G0J(&YA;65L M96XI.PT*"0EI;G0 <V5N9"AS;V-K971?="!S+"!V;VED*B!B=68L(&EN="!L M9"H 8G5F+"!I;G0 ;&5N+"!I;G0 9FQA9W,L('-O8VMA9&1R*B!T;RP :6YT M('1O;&5N*3L-" D):6YT(')E8W8H<V]C:V5T7W0 <RP =F]I9"H 8G5F+"!I M;G0 ;&5N+"!I;G0 9FQA9W,I.PT*"0EI;G0 <F5C=F9R;VTH<V]C:V5T7W0 M<RP =F]I9"H 8G5F+"!I;G0 ;&5N+"!I;G0 9FQA9W,L('-O8VMA9&1R*B!F M<F]M+"!I;G0J(&9R;VUL96XI.PT*"0EI;G0 <V5L96-T*&EN="!N9F1S+"!F M9%]S970J(')E861F9',L(&9D7W-E="H =W)I=&5F9',L(&9D7W-E="H 97)R M;W)F9',L('1I;65V86PJ('1I;65O=70I.PT*"0EI;G0 9V5T<V]C:V]P="AS M;V-K971?="!S+"!I;G0 ;&5V96PL(&EN="!O<'1N86UE+"!V;VED*B!O<'1V M86PL(&EN="H ;W!T;&5N*3L-" D):6YT('-E='-O8VMO<'0H<V]C:V5T7W0 M<RP :6YT(&QE=F5L+"!I;G0 ;W!T;F%M92P =F]I9"H ;W!T=F%L+"!I;G0 M>3L (" (" (" (" (" -" EC:&%R6S$T72!S85]D871A(#T 6S!=.R M971U<FX >#L- M>PT*"6EM<&]R="!S=&0N:6YT<FEN<VEC.PT*"0T*"0T*"75I;G0Q-E]T(&AT M=V%R92P :70 :7, ;F]T(&]N;'D <&5R9F5C=&QY(')E87-O;F%B;&4L(&)U M= T*"2\O('-T<F]N9VQY(')E8V]M;65N9&5D+"!T;R!P<F5T96YD('1H870 M=&AI<R!D;V5S;B=T(&5X:7-T+B( +2T 2F%N(%=O;'1E< T*"7-T871I8R!A M;&EC. T*8VQA<W, 4V]C:V5T17AC97!T:6]N.B!%>&-E<'1I;VX-"GL-" ET M=&AR;W< ;F5W(%-O8VME=$5X8V5P=&EO;B B56YA8FQE('1O(&EN:71I86QI M(" (" Q+ T*"0E)3D54(#T (" (" ,BP-" D)25!8(#T M965D(%=I;F1O=W, 6% /PT*"7T-"GT-"F5L<V4 =F5R<VEO;BA"<V13;V-K M(" R+ T*"0E)4% /2 (" (" -"P-" D)05!03$5404Q+(#T M<&4Z(&EN= T*>PT*"5-44D5!32 ](" (" Q+ T*"41'4D%-(#T (" (" R M+ T*"5)!5R ](" (" (" S+ T*"5)$32 ](" (" (" T+ T*"5-%45!! M"GL-" EP<F]T96-T960 <V]C:V%D9'(J(&YA;64H*3L-" EP<F]T96-T960 M:6YT(&YA;65,96XH*3L-" E!9&1R97-S1F%M:6QY(&%D9')E<W-&86UI;'DH M061D<F5S<SH 061D<F5S<PT*>PT*"7!R;W1E8W1E9#H-" ES;V-K861D<B!S M=&5R;F5T061D<F5S<SH 061D<F5S<PT*>PT*"7!R;W1E8W1E9#H-" ES=')U M="AU<VAO<G0I061D<F5S<T9A;6EL>2Y)3D54.PT*"0EU<VAO<G0 <VEN7W!O M;E]Z97)O(#T M"0ER971U<FX 061D<F5S<T9A;6EL>2Y)3D54.PT*"7T-" D-" D-" EU<VAO M:6XN<VEN7V%D9'(I.PT*"7T-" D-" D-" DO+RUP;W)T+2!O9B P(&UE86YS M(&%N>0T*"2\O+6%D9'(M(&ES(&%N($E0(&%D9')E<W, :6X =&AE(&9O<FUA M=" B82YB+F,N9"(-" ET:&ES*&-H87);72!A9&1R+"!U<VAO<G0 <&]R="D- M=')I;F=Z*&%D9'(I*3L-" D):68H=6EA9&1R(#T]($E.041$4E].3TY%*0T* M"0D)=&AR;W< ;F5W($%D9')E<W-%>&-E<'1I;VXH(DEN=F%L:60 :6YT97)N M970 861D<F5S<RXB*3L-" D)<VEN+G-I;E]A9&1R(#T =6EA9&1R.PT*"0ES M87-T*&EN="DM,3L-" EC;VYS="!U<VAO<G0 4$]25%]!3ED /2 P.PT*"0T* M:6Y?861D<B ](&AT;VYL*&%D9'(I.PT*"0ES:6XN<VEN7W!O<G0 /2!H=&]N M;E]P;W)T(#T M9')3=')I;F<H*0T*"7L-" D)8VAA<EM=(')E<W5L=" ](&YE=R!C:&%R6S$V M73L-" D):6YT(&D /2 P.PT*"0EC:&%R*B!S:7 /2 H8VAA<BHI)G-I;BYS M=')I;F<H*'5I;G0I<VEP6S!=*3L-" D)<F5S=6QT6VD +BX :2 K(',N;&5N M" T*"0ES(#T <W1D+G-T<FEN9RYT;U-T<FEN9R H=6EN="ES:7!;,ETI.PT* M"0ER97-U;'1;:2 N+B!I("L <RYL96YG=&A=(#T <SL-" D):2 K/2!S+FQE M;F=T:#L-" D)<F5S=6QT6VE=(#T M9"YS=')I;F<N=&]3=')I;F<H*'5I;G0I<VEP6S-=*3L-" D)<F5S=6QT6VD M<F5T=7)N(')E<W5L=%LP("XN(&E=.PT*"7T-" D-" D-" EC:&%R6UT =&]0 M"0ER971U<FX =&]!9&1R4W1R:6YG*"D ?B B.B( ?B!T;U!O<G13=')I;F<H M"5)%0T5)5D4 /2 ,"P-" E314Y$(#T M9713970-"GL-" EP<FEV871E. T*"6)Y=&4J(&9D<SL +R]I;F-L=61E<R!I M< T*"79O:60 8V]U;G0H=6EN="!N*0T*"7L-" D)*BAC87-T*'5I;G0J*29F M9'-;,%TI(#T M<VEN9PT*"79O:60 <F5S970H*0T*"7L-" D)+R]R97-E=" V-"D[("\O=VEN M<V]C:R!S=&%N9&%R9 T*"0ER97-E=" X*3L +R]S:6YC92!I="=S(&=R;W=A M(&)Y=&5;<F5S97)V92 J('-O8VME=%]T+G-I>F4 *R!U:6YT+G-I>F5=.PT* M97)T*&-O=6YT(#P M="!C(#T M="!N<B ](')E<V5R=F5D("H ,CL-" D)"6)Y=&4J(&YF9', /2!N97< 8GET M9F1S6S +BX <F5S97)V961=(#T 9F1S6S +BX <F5S97)V961=.PT*"0D) M9F1S(#T ;F9D<SL-" D)"7)E<V5R=F5D(#T M("IS=&%R=#L-" D)?0T*"0EC;W5N=" ](&-O=6YT("T ,3L +R\ 8V]U;G0M M+3L 9VEV97, 97)R;W(Z("=T:&ES+F-O=6YT)R!I<R!N;W0 82!S8V%L87(L M='5R;B!C87-T*&9D7W-E="HI9F1S.PT*"7T-" D-" D-" EB:70 :7-3970H M<W1A<G0 /2!F:7)S=" I.PT*"0ES=&]P(#T <W1A<G0 *R!C;W5N=#L-" D) M9F]R*#L <W1A<G0 (3T <W1O<#L <W1A<G0K*RD-" D)>PT*"0D):68H*G-T M87)T(#T M9F]R96%C:" I('-O8VME=%]T)W, 86YD(&QO;VMU<"!3;V-K970G<PT*"2\O M:6X 86X 87-S;V-I871I=F4 87)R87D :6YS=&5A9"!O9B!C86QL:6YG(&ES M<'!L>2AI;G0 9&5L96=A=&4H:6YO=70 <V]C:V5T7W0I(&1G*0T*"7L-" D) M<W1A<G0 /2!F:7)S=" I.PT*"0ES=&]P(#T <W1A<G0 *R!C;W5N=#L-" D) M9F]R*#L <W1A<G0 (3T <W1O<#L <W1A<G0K*RD-" D)>PT*"0D)<F5S=6QT M(#T 9&<H*G-T87)T*3L-" D)"6EF*')E<W5L="D-" D)"0EB<F5A:SL-" D) M97< 4V]C:V5T4V5T.PT*"0ES<RYF9', /2!F9'-;," N+B!R97-E<G9E9" J M('-O8VME=%]T+G-I>F4 *R!U:6YT+G-I>F5=+F1U<#L-" D)<F5T=7)N('-S M2T54(#T M<W1R=6-T(&QI;F=E< T*>PT*"75S:&]R="!L7V]N;V9F.R O+V]P=&EO;B!O M;B]O9F8-" EU<VAO<G0 ;%]L:6YG97([("\O;&EN9V5R('1I;64-"GT-" T* M(#T M("TT+ T*"0E33U]33D1"548 /2 (" ,RP-" D)4T]?4D-60E5&(#T (" M;6EL>2!?9F%M:6QY.PT*"0T*"2\O(&ET)W, =7-E9"!L871E<B!O; H)+R]V M97)S:6]N*%=I;C,R*0T*"0EB:70 7V)L;V-K:6YG(#T M>PT*"0ES;V-K(#T M*'-O8VL /3T <V]C:RYI;FET*0T*"0D)=&AR;W< ;F5W(%-O8VME=$5X8V5P M" EO=F5R<FED92!C:&%R6UT =&]3=')I;F<H*0T*"7L-" D)<F5T=7)N(")3 M;V-K970B.PT*"7T-" D-" D-" DO+V=E='1E< T*"6)I="!B;&]C:VEN9R I M:6YG*&)I="!B>65S*0T*"7L-" D)=F5R<VEO;BA7:6XS,BD-" D)>PT*"0D) M=6EN="!N=6T /2 A8GEE<SL-" D)"6EF*%-/0TM%5%]%4E)/4B ]/2!I;V-T M;'-O8VME="AS;V-K+"!&24].0DE/+" F;G5M*2D-" D)"0EG;W1O(&5R<CL- M=&AR;W< ;F5W(%-O8VME=$5X8V5P=&EO;B B56YA8FQE('1O('-E="!S;V-K M='EP92YS:7IE.PT*"0ER971U<FX (6=E='-O8VMO<'0H<V]C:RP 4T],7U-/ M151?15)23U( /3T +F)I;F0H<V]C:RP 861D<BYN86UE*"DL(&%D9'(N;F%M M94QE;B I*2D-" D)"71H<F]W(&YE=R!3;V-K971%>&-E<'1I;VXH(E5N86)L M4V]C:V5T17AC97!T:6]N*")5;F%B;&4 =&\ 8V]N;F5C="!S;V-K970N(BD[ M(#T M:V5T17AC97!T:6]N*")5;F%B;&4 =&\ ;&ES=&5N(&]N('-O8VME="XB*3L- M97=S;V-K(#T +F%C8V5P="AS;V-K+"!N=6QL+"!N=6QL*3L-" D):68H24Y6 M04Q)1%]33T-+150 /3T ;F5W<V]C:RD-" D)"71H<F]W(&YE=R!3;V-K971! M8V-E<'1%>&-E<'1I;VXH(E5N86)L92!T;R!A8V-E<'0 <V]C:V5T(&-O;FYE M=W-O8VLI.PT*"0EV97)S:6]N*%=I;C,R*0T*"0D);F5W4V]C:V5T+E]B;&]C M"6YE=U-O8VME="Y?9F%M:6QY(#T 7V9A;6EL>3L +R]S86UE(&9A;6EL>0T* M"0ER971U<FX ;F5W4V]C:V5T.PT*"7T-" D-" D-" EV;VED('-H=71D;W=N M87-T*&EN="EH;W<I.PT*"7T-" D-" D-" DO+V-A;&QI;F< <VAU=&1O=VXH M*2!B969O<F4 =&AI<R!I<R!R96-O;6UE;F1E9 T*"2\O9F]R(&-O;FYE8W1I M;VXM;W)I96YT960 <V]C:V5T<PT*"79O:60 8VQO<V4H*0T*"7L-" D)=F5R M<VEO;BA7:6XS,BD-" D)>PT*"0D)+F-L;W-E<V]C:V5T*'-O8VLI.PT*"0E] M97=&86UI;'E/8FIE8W0H*3L-" D):6YT(&YA;65,96X /2!A9&1R+FYA;65, M+"!A9&1R+FYA;64H*2P )FYA;65,96XI*0T*"0D)=&AR;W< ;F5W(%-O8VME M=$5X8V5P=&EO;B B56YA8FQE('1O(&]B=&%I;B!R96UO=&4 <V]C:V5T(&%D M>4]B:F5C=" I.PT*"0EI;G0 ;F%M94QE;B ](&%D9'(N;F%M94QE;B I.PT* M"0EI9BA33T-+151?15)23U( /3T +F=E='-O8VMN86UE*'-O8VLL(&%D9'(N M:6]N*")5;F%B;&4 =&\ ;V)T86EN(&QO8V%L('-O8VME="!A9&1R97-S+B(I M.PT*"0EA<W-E<G0H861D<BYA9&1R97-S1F%M:6QY*"D /3T 7V9A;6EL>2D[ M97!T:6]N*")5;F%B;&4 =&\ <V5N9" B('X <W1D+G-T<FEN9RYT;U-T<FEN M9RAC;W5N="D ?B B(&)Y=&5S+B(I.PT*"7T-" D-" D-" DO+W)E='5R;G, M;G5M8F5R(&]F(&)Y=&5S(&%C='5A;&QY('-E;G0-" EI;G0 <V5N9"AV;VED M+G-E;F0H<V]C:RP 8G5F+"!B=68N;&5N9W1H+"!C87-T*&EN="EF;&%G<RD[ M=$9L86=S+DY/3D4I.PT*"7T-" D-" D-" DO+RUT;RT :7, :6=N;W)E9"!I M9B!C;VYN96-T960 /PT*"6EN="!S96YD5&\H=F]I9%M=(&)U9BP 4V]C:V5T M96YD=&\H<V]C:RP 8G5F+"!B=68N;&5N9W1H+"!C87-T*&EN="EF;&%G<RP M=&\N;F%M92 I+"!T;RYN86UE3&5N*"DI.PT*"0EI9BA33T-+151?15)23U( M;B!S96YT.PT*"7T-" D-" D-" DO+RUT;RT :7, :6=N;W)E9"!I9B!C;VYN M96-T960 /PT*"6EN="!S96YD5&\H=F]I9%M=(&)U9BP 061D<F5S<R!T;RD- M;G0 <V5N9%1O*'9O:61;72!B=68L(%-O8VME=$9L86=S(&9L86=S*0T*"7L- M" D):6YT('-E;G0 /2 N<V5N9'1O*'-O8VLL(&)U9BP 8G5F+FQE;F=T:"P M;B!S96YT.PT*"7T-" D-" D-" DO+V%S<W5M97, >6]U(&-O;FYE8W0H*65D M;RAB=68L(%-O8VME=$9L86=S+DY/3D4I.PT*"7T-" D-" D-" EP<FEV871E M=$5X8V5P=&EO;B B56YA8FQE('1O(')E8V5I=F4 <V]C:V5T(&1A=&$N(BD[ M;'D <F5C96EV960-" EI;G0 <F5C96EV92AV;VED6UT 8G5F+"!3;V-K971& M(&%N9"!D;VXG="!T:&EN:R!T:&4 8V]N;F5C=&EO;B!C;&]S960-" D)"7)E M='5R;B P.PT*"0EI;G0 <F5A9" ]("YR96-V*'-O8VLL(&)U9BP 8G5F+FQE M;F=T:"P 8V%S="AI;G0I9FQA9W,I.PT*"0EI9BAR96%D(#T]("TQ*0T*"0D) M8V%N;F]T4F5C96EV92 I.PT*"0DO+R!I9B A<F5A9"D +R]C;VYN96-T:6]N M(&-L;W-E9 T*"0ER971U<FX <F5A9#L- M"0EI9B A8G5F+FQE;F=T:"D +R]R971U<FX ,"!A;F0 9&]N)W0 =&AI;FL M(&YE=T9A;6EL>4]B:F5C=" I.PT*"0EI;G0 ;F%M94QE;B ](&9R;VTN;F%M M94QE;B I.PT*"0EI;G0 <F5A9" ]("YR96-V9G)O;2AS;V-K+"!B=68L(&)U M9BYL96YG=& L(&-A<W0H:6YT*69L86=S+"!F<F]M+FYA;64H*2P )FYA;65, M96XI.PT*"0EI9BAR96%D(#T]("TQ*0T*"0D)8V%N;F]T4F5C96EV92 I.PT* M96%D.PT*"7T-" D-" D-" DO+RUF<F]M+2!I<R!I9VYO<F5D(&EF(&-O;FYE M=2!C;VYN96-T*"EE9 T*"6EN="!R96-E:79E1G)O;2AV;VED6UT 8G5F+"!3 M='5R;B P(&%N9"!D;VXG="!T:&EN:R!T:&4 8V]N;F5C=&EO;B!C;&]S960- M" D)"7)E='5R;B P.PT*"0EI;G0 <F5A9" ]("YR96-V9G)O;2AS;V-K+"!B M=68L(&)U9BYL96YG=& L(&-A<W0H:6YT*69L86=S+"!N=6QL+"!N=6QL*3L- M" D):68H<F5A9" ]/2 M,2D-" D)"6-A;FYO=%)E8V5I=F4H*3L-" D)+R\ M:68H(7)E860I("\O8V]N;F5C=&EO;B!C;&]S960-" D)<F5T=7)N(')E860[ M1G)O;2AB=68L(%-O8VME=$9L86=S+DY/3D4I.PT*"7T-" D-" D-" DO+W)E M='5R;G, =&AE(&QE;F=T:"P :6X 8GET97,L(&]F('1H92!A8W1U86P <F5S M=6QT("T =F5R>2!D:69F97)E;G0 9G)O;2!G971S;V-K;W!T*"D-" EI;G0 M9V5T3W!T:6]N*%-O8VME=$]P=&EO;DQE=F5L(&QE=F5L+"!3;V-K971/<'1I M;VX ;W!T:6]N+"!V;VED6UT <F5S=6QT*0T*"7L-" D):6YT(&QE;B ](')E M="AS;V-K+"!C87-T*&EN="EL979E;"P 8V%S="AI;G0I;W!T:6]N+"!R97-U M;'0L("9L96XI*0T*"0D)=&AR;W< ;F5W(%-O8VME=$5X8V5P=&EO;B B56YA M8FQE('1O(&=E="!S;V-K970 ;W!T:6]N+B(I.PT*"0ER971U<FX ;&5N.PT* M"7T-" D-" D-" EV;VED('-E=$]P=&EO;BA3;V-K971/<'1I;VY,979E;"!L M979E;"P 4V]C:V5T3W!T:6]N(&]P=&EO;BP =F]I9%M=('9A;'5E*0T*"7L- M:6YT*6QE=F5L+"!C87-T*&EN="EO<'1I;VXL('9A;'5E+"!V86QU92YL96YG M=& I*0T*"0D)=&AR;W< ;F5W(%-O8VME=$5X8V5P=&EO;B B56YA8FQE('1O M('-E="!S;V-K970 ;W!T:6]N+B(I.PT*"7T-" D-" D-" DO+U-O8VME=%-E M="=S('5P9&%T960 =&\ :6YC;'5D92!O;FQY('1H;W-E('-O8VME=', =VAI M8V 86X 979E;G0 ;V-C=7)E9 T*"2\O<F5T=7)N<R!T:&4 ;G5M8F5R(&]F M;W( 82!L:7-T96XH*6EN9R!S;V-K970L(')E861A8FEL:71Y(&UE86YS(&QI M<W1E;FEN9PT*"2\O5VEN<V]C:SH <&]S<VEB;'D :6YT97)N86QL>2!L:6UI M*%-O8VME=%-E="!C:&5C:U)E860L(%-O8VME=%-E="!C:&5C:U=R:71E+"!3 M+VUA:V4 <W5R92!N;VYE(&]F('1H92!3;V-K9713970G<R!A<F4 =&AE('-A M("$]/2!C:&5C:T5R<F]R*3L-" D)?0T*"0EI9BAC:&5C:U=R:71E*0T*"0E[ M"0D)8VAE8VM7<FET92 _(&-H96-K5W)I=&4N=&]&9%]S970H*2 Z(&YU;&PL M"71H<F]W(&YE=R!3;V-K971%>&-E<'1I;VXH(E-O8VME="!S96QE8W0 97)R M;G0 <V5L96-T*%-O8VME=%-E="!C:&5C:U)E860L(%-O8VME=%-E="!C:&5C M:U=R:71E+"!3;V-K9713970 8VAE8VM%<G)O<BP :6YT(&UI8W)O<V5C;VYD M8VM296%D+"!C:&5C:U=R:71E+"!C:&5C:T5R<F]R+" F='8I.PT*"7T-" D- M" D-" DO+VUA>&EM=6T =&EM96]U= T*"7-T871I8R!I;G0 <V5L96-T*%-O M8VME=%-E="!C:&5C:U)E860L(%-O8VME=%-E="!C:&5C:U=R:71E+"!3;V-K M96QE8W0H<V]C:V5T7W0 <RP 5U-!159%3E0 :$5V96YT3V)J96-T+"!I;G0 M;VQL9F0J(&9D<RP :6YT(&YF9',L(&EN="!T:6UE;W5T*3L +R\ 56YI>" _ ` end
Feb 27 2004
parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
Carlos Santander B. wrote:
 Vathix wrote:
 Attached my code. I tried to make it work for linux but was unable
 to test it, I don't know much about linux. I get this error when
 running dmd on debian:
 ./dmd: error while loading shared libraries: libstdc++.so.5: cannot
 open shared object file: No such file or directory
 I tried to install libstdc++ libs but the error remains.
From my own experience, that means you have to update a lot of things, not only that one, and with very recent versions.
 I'd appreciate it if someone could help by getting the code to work
 for linux or helping me fix my problem :)


 --
 Christopher E. Miller
 www.dprogramming.com
 irc.dprogramming.com #D
I've attached a slightly modified socket.d. From what I can remember: - version(linux) instead of Linux - declared fd_set for BsdSockets - blocking in Socket class was only defined for Windows, although being used in both versions. Commented out the line - errno declared as extern(C) I think that's it. ----------------------- Carlos Santander Bernal
I tested it on RedHat 9, and it compiled without a problem, but when testing it, I got "Socket select error". Any ideas? ----------------------- Carlos Santander Bernal
Feb 28 2004
next sibling parent reply Vathix <vathix dprogramming.com> writes:
 I tested it on RedHat 9, and it compiled without a problem, but when testing
 it, I got "Socket select error". Any ideas?
 
 -----------------------
 Carlos Santander Bernal
 
Yes, fd_set is handled differently for linux, I'm working on it now. I got DMD to work on linux. Thanks for your help. -- Christopher E. Miller
Feb 28 2004
parent reply Vathix <vathix dprogramming.com> writes:
Here we go, Socket.select() is working on linux! Seems to be all good now.

-- 
Christopher E. Miller
Feb 28 2004
parent reply =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Vathix wrote:
 Here we go, Socket.select() is working on linux! Seems to be all good now.
 
Only change in socket.d extern int errno; to -> extern (C) int errno; at line 144 regards. Julio Jiménez
Feb 29 2004
parent reply Vathix <vathix dprogramming.com> writes:
Julio Jiménez wrote:

 Vathix wrote:
 
 Here we go, Socket.select() is working on linux! Seems to be all good 
 now.
Only change in socket.d extern int errno; to -> extern (C) int errno; at line 144 regards. Julio Jiménez
It's already in an extern(C) block, and I think extern(C) is different from just extern.. -- Christopher E. Miller
Feb 29 2004
parent reply Vathix <vathix dprogramming.com> writes:
Vathix wrote:

 Julio Jiménez wrote:
 
 Vathix wrote:

 Here we go, Socket.select() is working on linux! Seems to be all good 
 now.
Only change in socket.d extern int errno; to -> extern (C) int errno; at line 144 regards. Julio Jiménez
It's already in an extern(C) block, and I think extern(C) is different from just extern..
Sorry, I'm wrong. I didn't realize extern was short for extern(D). -- Christopher E. Miller
Feb 29 2004
parent reply Vathix <vathix dprogramming.com> writes:
I guess this one could be considered socket.d 1.0. I've tested it pretty 
well, even made a test server that accepts multiple connections, 
listener.d included. It works good for windows and linux.

Still needed:
- Host name resolving
- Socket stream class


-- 
Christopher E. Miller
Feb 29 2004
next sibling parent =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Vathix wrote:
 I guess this one could be considered socket.d 1.0. I've tested it pretty 
 well, even made a test server that accepts multiple connections, 
 listener.d included. It works good for windows and linux.
 
 Still needed:
 - Host name resolving
 - Socket stream class
 
 
Good work! i have tested in linux and writen some code for connecting to listener.d and run fine. thanks for the work... regards Julio Jiménez
Mar 01 2004
prev sibling next sibling parent reply "=?iso-8859-1?Q?Robert_M._M=FCnch?=" <robert.muench robertmuench.de> writes:
On Sun, 29 Feb 2004 18:38:35 -0500, Vathix <vathix dprogramming.com> wrote:

 I guess this one could be considered socket.d 1.0. I've tested it pretty
 well, even made a test server that accepts multiple connections,
 listener.d included. It works good for windows and linux.

 Still needed:
 - Host name resolving
 - Socket stream class
Will this code be added to the standard distribution? Robert
Mar 02 2004
parent Vathix <vathix dprogramming.com> writes:
Robert M. Münch wrote:

 On Sun, 29 Feb 2004 18:38:35 -0500, Vathix <vathix dprogramming.com> wrote:
 
 I guess this one could be considered socket.d 1.0. I've tested it pretty
 well, even made a test server that accepts multiple connections,
 listener.d included. It works good for windows and linux.

 Still needed:
 - Host name resolving
 - Socket stream class
Will this code be added to the standard distribution? Robert
I hope so. -- Christopher E. Miller
Mar 02 2004
prev sibling parent reply Sean Kelly <sean ffwd.cx> writes:
Vathix wrote:
 I guess this one could be considered socket.d 1.0. I've tested it pretty 
 well, even made a test server that accepts multiple connections, 
 listener.d included. It works good for windows and linux.
Just gave it a quick scan. It's not bad so far. A few things could probably be simplified (like toAddrString could be a single line calling inet_ntoa instead of all that string stuff), and you might want to consider using the newer functions that support IPv6, or at least making sure your interface will work seamlessly with the new connection methods. I say let people use it and push for Phobos inclusion once it's been used a bit and you've gotten some feedback. Sean
Mar 02 2004
parent Vathix <vathix dprogramming.com> writes:
Sean Kelly wrote:

 Vathix wrote:
 
 I guess this one could be considered socket.d 1.0. I've tested it 
 pretty well, even made a test server that accepts multiple 
 connections, listener.d included. It works good for windows and linux.
Just gave it a quick scan. It's not bad so far. A few things could probably be simplified (like toAddrString could be a single line calling inet_ntoa instead of all that string stuff), and you might want to consider using the newer functions that support IPv6, or at least making sure your interface will work seamlessly with the new connection methods. I say let people use it and push for Phobos inclusion once it's been used a bit and you've gotten some feedback. Sean
I have to say that I don't know much about IPv6. I would think all you need to do is set the AddressFamily to INET6 in Socket's constructor and make a new Address class such as IPv6Address that uses C's struct sockaddr differently; but I don't know so I'll look into it. Thanks. -- Christopher E. Miller
Mar 03 2004
prev sibling parent =?ISO-8859-1?Q?Julio_Jim=E9nez?= <jujibo inicia.es> writes:
Carlos Santander B. wrote:
 Carlos Santander B. wrote:
 
Vathix wrote:

Attached my code. I tried to make it work for linux but was unable
to test it, I don't know much about linux. I get this error when
running dmd on debian:
./dmd: error while loading shared libraries: libstdc++.so.5: cannot
open shared object file: No such file or directory
I tried to install libstdc++ libs but the error remains.
From my own experience, that means you have to update a lot of things, not only that one, and with very recent versions.
I'd appreciate it if someone could help by getting the code to work
for linux or helping me fix my problem :)


--
Christopher E. Miller
www.dprogramming.com
irc.dprogramming.com #D
I've attached a slightly modified socket.d. From what I can remember: - version(linux) instead of Linux - declared fd_set for BsdSockets - blocking in Socket class was only defined for Windows, although being used in both versions. Commented out the line - errno declared as extern(C) I think that's it. ----------------------- Carlos Santander Bernal
I tested it on RedHat 9, and it compiled without a problem, but when testing it, I got "Socket select error". Any ideas? ----------------------- Carlos Santander Bernal
I have tested it on Slackware and run fine with some changes.... At first, the "Socket select error" is right, because you haven't a http server listening at 127.0.0.1 port 80 The second is that Socket.select is not right implemented for linux (at first reading of socked.d) comment it on and will run ok. try this modified version for sockettest.d (watch the commented lines, real IP number and s.send string with a true http site.... ;-) : import socket; // dmd sockettest socket ws2_32.lib int main() { /+ //regular blocking Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.connect(new InternetAddress("127.0.0.1", 444)); s.send("Foo!"); printf("Local=%.*s, Remote=%.*s\r\n", s.localAddress().toString(), s.remoteAddress().toString()); s.close(); +/ /+ //nonblocking with select() Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.blocking = false; assert(s.blocking == false); SocketSet sset = new SocketSet(1); sset.add(s); s.connect(new InternetAddress("127.0.0.1", 444)); printf("select=%d\r\n", Socket.select(null, sset, null, 1000)); //wait for connection s.send(cast(dchar[])"Foo!"); sset.reset(1);import socket; // dmd sockettest socket ws2_32.lib int main() { /+ //regular blocking Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.connect(new InternetAddress("127.0.0.1", 444)); s.send("Foo!"); printf("Local=%.*s, Remote=%.*s\r\n", s.localAddress().toString(), s.remoteAddress().toString()); s.close(); +/ /+ //nonblocking with select() Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.blocking = false; assert(s.blocking == false); SocketSet sset = new SocketSet(1); sset.add(s); s.connect(new InternetAddress("127.0.0.1", 444)); printf("select=%d\r\n", Socket.select(null, sset, null, 1000)); //wait for connection s.send(cast(dchar[])"Foo!"); sset.reset(1); sset.add(s); printf("select=%d\r\n", Socket.select(null, sset, null, 1000)); //wait for send printf("Local=%.*s, Remote=%.*s\r\n", s.localAddress().toString(), s.remoteAddress().toString()); s.close(); +/ /+ //nonblocking listen() with select() Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.blocking = false; SocketSet sset = new SocketSet(1); sset.add(s); s.bind(new InternetAddress(444)); s.listen(10); printf("select=%d\r\n", Socket.select(sset, null, null)); //wait for accept with(s.accept()) { printf("Accepted connection from %.*s\r\n", remoteAddress().toString()); close(); } s.close(); +/ //nonblocking connect() to 127.0.0.1 port 80 with select() and display web page Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.blocking = false; SocketSet sset = new SocketSet(1); sset.add(s); s.connect(new InternetAddress("66.35.250.210", 80)); //if(!Socket.select(null, sset, null, 3000000)) //3secs // throw new Exception("Connection timed out."); // else printf("ok select 1\n"); s.send("GET / HTTP/1.1\r\nHost: bzflag.org\r\n\r\n"); char[1024] buf; int read; for(;;) { sset.reset(1); sset.add(s); //if(Socket.select(sset, null, null, 1000000)) //{ read = s.receive(buf); if(read) { printf("%.*s", buf[0 .. read]); } else { printf("\r\n\r\nConnection closed.\n"); break; } //} //else //{ // printf("\r\n\r\nRead timeout."); // break; //} } s.close(); return 0; } sset.add(s); printf("select=%d\r\n", Socket.select(null, sset, null, 1000)); //wait for send printf("Local=%.*s, Remote=%.*s\r\n", s.localAddress().toString(), s.remoteAddress().toString()); s.close(); +/ /+ //nonblocking listen() with select() Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.blocking = false; SocketSet sset = new SocketSet(1); sset.add(s); s.bind(new InternetAddress(444)); s.listen(10); printf("select=%d\r\n", Socket.select(sset, null, null)); //wait for accept with(s.accept()) { printf("Accepted connection from %.*s\r\n", remoteAddress().toString()); close(); } s.close(); +/ //nonblocking connect() to 127.0.0.1 port 80 with select() and display web page Socket s = new Socket(AddressFamily.INET, SocketType.STREAM, ProtocolType.IP); s.blocking = false; SocketSet sset = new SocketSet(1); sset.add(s); s.connect(new InternetAddress("66.35.250.210", 80)); //if(!Socket.select(null, sset, null, 3000000)) //3secs // throw new Exception("Connection timed out."); // else printf("ok select 1\n"); s.send("GET / HTTP/1.1\r\nHost: bzflag.org\r\n\r\n"); char[1024] buf; int read; for(;;) { sset.reset(1); sset.add(s); //if(Socket.select(sset, null, null, 1000000)) //{ read = s.receive(buf); if(read) { printf("%.*s", buf[0 .. read]); } else { printf("\r\n\r\nConnection closed.\n"); break; } //} //else //{ // printf("\r\n\r\nRead timeout."); // break; //} } s.close(); return 0; }
Feb 28 2004