 |
cato |
| [C] winsok e MinGw |
07-03-2005 16:03 |
|
 |
cato |
Wild boys always shine

Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline
Edit | Report | IP: Logged |
[C] winsok e MinGw
sto usando dev-c++ che si basa su MinGW per qualche programma con le socket.
ma quando compilo il linker fallisce...
sapete se c'e' qualche parametro da settare?grazie,
__________________
code: , , | | Me@Flickr
[ov0] | | my photo Blog
{| |} |@| Pallavolo La Nuova Rossa Milano
--"-"--| |
-------| | "If You Can't Open It, You Don't Own It"
|
|
07-03-2005 16:03 |
|
|
|  |
 |
DeepBlue |
| con che messaggio fallisce?
... |
07-03-2005 16:12 |
|
 |
DeepBlue |
tired guy

Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline
Edit | Report | IP: Logged |
con che messaggio fallisce?
stai compilando programmi che utilizzano socket sotto win? Se sì, ricordati che gli header di rete probabilmente cambiano: devi usare winsock.h e winsock2.h
__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~
|
|
07-03-2005 16:12 |
|
|
|  |
 |
cato |
| [Linker error] undefined reference to `socket@12' ... |
07-03-2005 17:06 |
|
 |
cato |
Wild boys always shine

Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline
Edit | Report | IP: Logged |
[Linker error] undefined reference to `socket@12' ad esempio
__________________
code: , , | | Me@Flickr
[ov0] | | my photo Blog
{| |} |@| Pallavolo La Nuova Rossa Milano
--"-"--| |
-------| | "If You Can't Open It, You Don't Own It"
|
|
07-03-2005 17:06 |
|
|
|  |
 |
cato |
| prendendo un esempio dal comer
... |
07-03-2005 17:19 |
|
 |
cato |
Wild boys always shine

Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline
Edit | Report | IP: Logged |
prendendo un esempio dal comer
ftp://ftp.cs.purdue.edu/pub/comer/
http://www.cs.purdue.edu/homes/dec/netbooks.html
code:
/* TCPecho.cpp - main, TCPecho */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <winsock.h>
void TCPecho(const char *, const char *);
void errexit(const char *, ...);
SOCKET connectTCP(const char *, const char *);
#define LINELEN 128
#define WSVERS MAKEWORD(2, 0)
/*------------------------------------------------------------------------
* main - TCP client for ECHO service
*------------------------------------------------------------------------
*/
int
main(int argc, char *argv[])
{
char *host = "localhost"; /* host to use if none supplied */
char *service = "echo"; /* default service name */
WSADATA wsadata;
switch (argc) {
case 1:
host = "localhost";
break;
case 3:
service = argv[2];
/* FALL THROUGH */
case 2:
host = argv[1];
break;
default:
fprintf(stderr, "usage: TCPecho [host [port]]\n");
exit(1);
}
if (WSAStartup(WSVERS, &wsadata) != 0)
errexit("WSAStartup failed\n");
TCPecho(host, service);
WSACleanup();
exit(0);
}
/*------------------------------------------------------------------------
* TCPecho - send input to ECHO service on specified host and print reply
*------------------------------------------------------------------------
*/
void
TCPecho(const char *host, const char *service)
{
char buf[LINELEN+1]; /* buffer for one line of text */
SOCKET s; /* socket descriptor */
int cc, outchars, inchars; /* characters counts */
s = connectTCP(host, service);
while (fgets(buf, sizeof(buf), stdin)) {
buf[LINELEN] = '\0'; /* ensure line null-termination */
outchars = strlen(buf);
(void) send(s, buf, outchars, 0);
/* read it back */
for (inchars = 0; inchars < outchars; inchars += cc) {
cc = recv(s, &buf[inchars], outchars-inchars, 0);
if (cc == SOCKET_ERROR)
errexit("socket recv failed: %d\n",
GetLastError());
}
fputs(buf, stdout);
}
closesocket(s);
}
non compila...mi da errori con il linker...
che parametri vanno dati al compilatore?
__________________
code: , , | | Me@Flickr
[ov0] | | my photo Blog
{| |} |@| Pallavolo La Nuova Rossa Milano
--"-"--| |
-------| | "If You Can't Open It, You Don't Own It"
Last edited by cato on 07-03-2005 at 17:21
|
|
07-03-2005 17:19 |
|
|
|  |
 |
DeepBlue |
| Sinceramente non so aiutarti.
... |
07-03-2005 19:29 |
|
|
|  |
 |
yeah |
| Hai incluso la libreria delle socket in Dev-cpp? I ... |
07-03-2005 20:30 |
|
 |
yeah |
.grande:maestro.

Registered: Nov 2003
Posts: 1644 (0.20 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline
Edit | Report | IP: Logged |
Hai incluso la libreria delle socket in Dev-cpp? Io uso solo mingw, senza IDE, quindi non so come si setta :/
se usi winsock.h devi linkare con wsock32
se invece usi winsock2.h devi linkare con ws2_32
__________________
?
|
|
07-03-2005 20:30 |
|
|
|  |
 |
fabpicca |
| io mi ricordo che per un problema di questo tipo i ... |
08-03-2005 11:04 |
|
 |
fabpicca |
jesus robot d'acciaio

Registered: May 2002
Posts: 2166 (0.25 al dì)
Location: Pieve Emanuele
Corso: Ticom
Anno: 1°
Time Online: 12 Days, 23:12:28 [...]
Status: Offline
Edit | Report | IP: Logged |
io mi ricordo che per un problema di questo tipo il progetto di reti in C l'ho fatto sotto linux...
__________________
my website?|ubuntu linux|get Firefox|grazie Polonia |bagdad sour
"Come va che non ha le corna e le zampe di Caprone?" gli opposi. "Oh, Giuvà", mi disse il prete "adesso non si usa più.Satana è furbo". (I.Silone, Fontamara)
"Al giorno d'oggi non bisogna essere intelligenti, perchè la gente si offende" (un ubriacone)
"close your eyes / pay the price / for your paradise" (DM) "whatever you want to change/you'd better start changing it in your mind" (Transatlantic)
|
|
08-03-2005 11:04 |
|
|
|  |
 |
cato |
| [QUOTE][i]Originally posted by yeah [/i]
... |
08-03-2005 12:07 |
|
 |
cato |
Wild boys always shine

Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline
Edit | Report | IP: Logged |
Originally posted by yeah
H
se usi winsock.h devi linkare con wsock32

__________________
code: , , | | Me@Flickr
[ov0] | | my photo Blog
{| |} |@| Pallavolo La Nuova Rossa Milano
--"-"--| |
-------| | "If You Can't Open It, You Don't Own It"
|
|
08-03-2005 12:07 |
|
|
|  |
 |
cato |
| mhh uso queste opzioni:
... |
14-03-2005 10:53 |
|
 |
cato |
Wild boys always shine

Registered: Nov 2001
Posts: 5608 (0.63 al dì)
Location: lecco
Corso: F28
Anno: dottore
Time Online: 38 Days, 5:42:41 [...]
Status: Offline
Edit | Report | IP: Logged |
mhh uso queste opzioni:
-lwsock32 -ladvapi32
e mi da questi errori:
[Linker error] undefined reference to `recv'
[Linker error] undefined reference to `send'
[Linker error] undefined reference to `bzero'
[Linker error] undefined reference to `bcopy'
M:\Vxx\vte\_ferrario\0307_onwork\wsocket\Makefile.win [Build Error] [Wsoket.exe] Error 1

__________________
code: , , | | Me@Flickr
[ov0] | | my photo Blog
{| |} |@| Pallavolo La Nuova Rossa Milano
--"-"--| |
-------| | "If You Can't Open It, You Don't Own It"
|
|
14-03-2005 10:53 |
|
|
|  |
 |
DeepBlue |
| per bzero e bcopy hai incluso memory.h? ... |
14-03-2005 13:20 |
|
 |
DeepBlue |
tired guy

Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline
Edit | Report | IP: Logged |
per bzero e bcopy hai incluso memory.h?
__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~
|
|
14-03-2005 13:20 |
|
|
|  |
 |
yeah |
| Dal tuo post precedente sembrava che wsock32 risol ... |
14-03-2005 20:46 |
|
 |
yeah |
.grande:maestro.

Registered: Nov 2003
Posts: 1644 (0.20 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline
Edit | Report | IP: Logged |
Dal tuo post precedente sembrava che wsock32 risolvesse il problema.
Gli errori sono arrivati dopo aver aggiunto qualcosa? Puoi postare il codice?
Eventualmente prova a scambiare wsock32 e advapi32:
-ladvapi32 -lwsock32
Off-Topic:
Carino memory.h incluso in Mingw
code:
/*
* This file is part of the Mingw32 package.
*
* memory.h maps to the standard string.h header.
*/
#ifndef __STRICT_ANSI__
#include <string.h>
#endif
Non me lo immaginavo 
Non sono sicuro, ma bzero() e bcopy() non esistono solo in Unix/Linux?
Forse no 
__________________
?
Last edited by yeah on 14-03-2005 at 20:50
|
|
14-03-2005 20:46 |
|
|
|  |
 |
| All times are GMT. The time now is 17:08. |
|
|
 |
|
 |
|
|
|  |
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|