6 Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
8 This file is part of simavr.
10 simavr is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
15 simavr is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with simavr. If not, see <http://www.gnu.org/licenses/>.
24 #include <netinet/in.h>
25 #include <netinet/tcp.h>
26 #include <arpa/inet.h>
27 #include <sys/socket.h>
36 typedef struct avr_gdb_t {
41 int avr_gdb_init(avr_t * avr)
43 avr_gdb_t * g = malloc(sizeof(avr_gdb_t));
44 memset(g, 0, sizeof(avr_gdb_t));
48 if ((g->sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
49 fprintf(stderr, "Can't create socket: %s", strerror(errno));
54 setsockopt(g->sock, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
56 struct sockaddr_in address = { 0 };
57 address.sin_family = AF_INET;
58 address.sin_port = htons (1234);
60 if (bind(g->sock, (struct sockaddr *) &address, sizeof(address))) {
61 fprintf(stderr, "Can not bind socket: %s", strerror(errno));